]> granicus.if.org Git - python/commitdiff
Try to prevent this test from being flaky. We might need a sleep in here
authorNeal Norwitz <nnorwitz@gmail.com>
Sun, 27 Jan 2008 05:02:34 +0000 (05:02 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Sun, 27 Jan 2008 05:02:34 +0000 (05:02 +0000)
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.

Will backport.

Lib/test/test_resource.py

index 3ff31bb33dd5be97b1c0e7fc3ee1ced32e29f0a2..f7c2976add4121fc00dbb76b63e9dcf374dc92c7 100644 (file)
@@ -54,8 +54,12 @@ class ResourceTest(unittest.TestCase):
                         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