mirror of https://github.com/python/cpython
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.
This commit is contained in:
parent
6384c66d1f
commit
32830149d8
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue