cleanup test_posix

This commit is contained in:
Victor Stinner 2014-10-05 17:37:59 +02:00
parent 047b7ae566
commit bed04a77ee

View file

@ -1127,16 +1127,17 @@ class PosixTester(unittest.TestCase):
""" """
for name in ("rename", "replace", "link"): for name in ("rename", "replace", "link"):
function = getattr(os, name, None) function = getattr(os, name, None)
if function is None:
continue
if function: for dst in ("noodly2", support.TESTFN):
for dst in ("noodly2", support.TESTFN): try:
try: function('doesnotexistfilename', dst)
function('doesnotexistfilename', dst) except OSError as e:
except OSError as e: self.assertIn("'doesnotexistfilename' -> '{}'".format(dst), str(e))
self.assertIn("'doesnotexistfilename' -> '{}'".format(dst), str(e)) break
break else:
else: self.fail("No valid path_error2() test for os." + name)
self.fail("No valid path_error2() test for os." + name)
class PosixGroupsTester(unittest.TestCase): class PosixGroupsTester(unittest.TestCase):