diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-03-25 14:12:08 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-03-25 14:12:08 (GMT) |
commit | 32830149d8873234eaf1949ef840c3a07ecf5b64 (patch) | |
tree | cd4f16c0acafdf233173911f21fc9fac540e144a /Lib/test | |
parent | 6384c66d1fec061240afc40d91c8cc73e9736a57 (diff) | |
download | cpython-32830149d8873234eaf1949ef840c3a07ecf5b64.zip cpython-32830149d8873234eaf1949ef840c3a07ecf5b64.tar.gz cpython-32830149d8873234eaf1949ef840c3a07ecf5b64.tar.bz2 |
changeset: 100749:0b61b2d28a07
tag: tip
parent: 100742:ebae81b31cf6
user: Victor Stinner <victor.stinner@gmail.com>
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.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_os.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index c8789d7..f7d64b7 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") |