changeset 77646:ed0510588e2b

Avoid depending on directory iteration order in test_shutil
author Antoine Pitrou <solipsis@pitrou.net>
date Sat, 23 Jun 2012 22:05:11 +0200
parents baaaed041e49
children 59ae57197bad
files Lib/test/test_shutil.py
diffstat 1 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/Lib/test/test_shutil.py	Sat Jun 23 21:32:36 2012 +0200
+++ b/Lib/test/test_shutil.py	Sat Jun 23 22:05:11 2012 +0200
@@ -158,14 +158,13 @@
         # be either.
         if support.verbose:
             print("onerror [%d]: %r" % (self.errorState, (func, arg, exc[1])))
-        if 0 <= self.errorState < 2:
+        if self.errorState < 2:
             if func is os.unlink:
-                self.assertIn(arg, [self.child_file_path, self.child_dir_path])
+                self.assertEqual(arg, self.child_file_path)
+            elif func is os.rmdir:
+                self.assertEqual(arg, self.child_dir_path)
             else:
-                if self.errorState == 1:
-                    self.assertEqual(func, os.rmdir)
-                else:
-                    self.assertIs(func, os.listdir, "func must be os.listdir")
+                self.assertIs(func, os.listdir)
                 self.assertIn(arg, [TESTFN, self.child_dir_path])
             self.assertTrue(issubclass(exc[0], OSError))
             self.errorState += 1