[Python-checkins] cpython: changeset: 100749:0b61b2d28a07
victor.stinner
python-checkins at python.org
Fri Mar 25 10:12:48 EDT 2016
https://hg.python.org/cpython/rev/27faabd712b3
changeset: 100749:27faabd712b3
user: Victor Stinner <victor.stinner at gmail.com>
date: Fri Mar 25 15:12:08 2016 +0100
summary:
changeset: 100749:0b61b2d28a07
tag: tip
parent: 100742:ebae81b31cf6
user: Victor Stinner <victor.stinner at 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.
files:
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
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -1427,7 +1427,16 @@
@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")
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list