]> granicus.if.org Git - python/commitdiff
Backport 60342:
authorNeal Norwitz <nnorwitz@gmail.com>
Sun, 27 Jan 2008 05:02:56 +0000 (05:02 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Sun, 27 Jan 2008 05:02:56 +0000 (05:02 +0000)
Try to prevent this test from being flaky.  We might need a sleep in here
which isn't as bad as it sounds.  The close() *should* raise an exception,
so if it didn't we should give more time to sync and really raise it.

Lib/test/test_resource.py

index 28876e3a211b5836a5b3ceb69decefe7a814b02f..86c7cc206ab2019b00dc33a48100d938a9c903e0 100644 (file)
@@ -37,8 +37,11 @@ try:
         f.write("Y")
         f.flush()
         # On some systems (e.g., Ubuntu on hppa) the flush()
-        # doesn't cause the exception, but the close() does.
-        f.close()
+        # doesn't always cause the exception, but the close()
+        # does eventually.  Try closing several times in an attempt
+        # to ensure the file is really synced and the exception raised.
+        for i in range(5):
+            f.close()
     except IOError:
         if not limit_set:
             raise