Skip to content

Commit

Permalink
Avoid depending on directory iteration order in test_shutil
Browse files Browse the repository at this point in the history
  • Loading branch information
pitrou committed Jun 23, 2012
1 parent f3a166d commit 4f6e3f7
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions Lib/test/test_shutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,13 @@ def check_args_to_onerror(self, func, arg, exc):
# 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
Expand Down

0 comments on commit 4f6e3f7

Please sign in to comment.