From: Victor Stinner Date: Fri, 25 Mar 2016 14:12:08 +0000 (+0100) Subject: changeset: 100749:0b61b2d28a07 X-Git-Tag: v3.6.0a1~328 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=32830149d8873234eaf1949ef840c3a07ecf5b64;p=thirdparty%2FPython%2Fcpython.git changeset: 100749:0b61b2d28a07 tag: tip parent: 100742:ebae81b31cf6 user: Victor Stinner date: Fri Mar 25 15:03:34 2016 +0100 files: Lib/test/test_os.py description: test_os: Win32ErrorTests checks if file exists Don't use os.path.exists() since it ignores *any* OSError. --- diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index c8789d72a717..f7d64b783894 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -1427,7 +1427,16 @@ class ExecTests(unittest.TestCase): @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests") class Win32ErrorTests(unittest.TestCase): def setUp(self): - self.assertFalse(os.path.exists(support.TESTFN)) + try: + os.stat(support.TESTFN) + except FileNotFoundError: + exists = False + except OSError as exc: + exists = True + self.fail("file %s must not exist; os.stat failed with %s" + % (support.TESTFN, exc)) + else: + self.fail("file %s must not exist" % support.TESTFN) def test_rename(self): self.assertRaises(OSError, os.rename, support.TESTFN, support.TESTFN+".bak")