summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_posixpath.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-06-16 10:58:10 (GMT)
committerGitHub <noreply@github.com>2018-06-16 10:58:10 (GMT)
commit5c23e21ef655db35af45ed98a62eb54bff64dbd0 (patch)
treed276887257fc9fad6864b81d3f80266203a4b30a /Lib/test/test_posixpath.py
parentc5ff553ae717c33f86d4fa984ee92de71c467f2a (diff)
downloadcpython-5c23e21ef655db35af45ed98a62eb54bff64dbd0.zip
cpython-5c23e21ef655db35af45ed98a62eb54bff64dbd0.tar.gz
cpython-5c23e21ef655db35af45ed98a62eb54bff64dbd0.tar.bz2
bpo-33861: Minor improvements of tests for os.path. (GH-7715)
* Test exists(), lexists(), isdir(), isfile(), islink(), ismount() with bytes paths. * Remove unneeded silencing DeprecationWarning for ismount() with bytes path. * Test common functions with unencodable and undecodable paths. * Minor clean up and refactoring. (cherry picked from commit 17a0088e2680e12ce2c5f2ffc6b71766299e38d5) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib/test/test_posixpath.py')
-rw-r--r--Lib/test/test_posixpath.py27
1 files changed, 10 insertions, 17 deletions
diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py
index 96b267c..9476ede 100644
--- a/Lib/test/test_posixpath.py
+++ b/Lib/test/test_posixpath.py
@@ -153,27 +153,20 @@ class PosixPathTest(unittest.TestCase):
def test_islink(self):
self.assertIs(posixpath.islink(support.TESTFN + "1"), False)
self.assertIs(posixpath.lexists(support.TESTFN + "2"), False)
- f = open(support.TESTFN + "1", "wb")
- try:
+ with open(support.TESTFN + "1", "wb") as f:
f.write(b"foo")
- f.close()
- self.assertIs(posixpath.islink(support.TESTFN + "1"), False)
- if support.can_symlink():
- os.symlink(support.TESTFN + "1", support.TESTFN + "2")
- self.assertIs(posixpath.islink(support.TESTFN + "2"), True)
- os.remove(support.TESTFN + "1")
- self.assertIs(posixpath.islink(support.TESTFN + "2"), True)
- self.assertIs(posixpath.exists(support.TESTFN + "2"), False)
- self.assertIs(posixpath.lexists(support.TESTFN + "2"), True)
- finally:
- if not f.close():
- f.close()
+ self.assertIs(posixpath.islink(support.TESTFN + "1"), False)
+ if support.can_symlink():
+ os.symlink(support.TESTFN + "1", support.TESTFN + "2")
+ self.assertIs(posixpath.islink(support.TESTFN + "2"), True)
+ os.remove(support.TESTFN + "1")
+ self.assertIs(posixpath.islink(support.TESTFN + "2"), True)
+ self.assertIs(posixpath.exists(support.TESTFN + "2"), False)
+ self.assertIs(posixpath.lexists(support.TESTFN + "2"), True)
def test_ismount(self):
self.assertIs(posixpath.ismount("/"), True)
- with warnings.catch_warnings():
- warnings.simplefilter("ignore", DeprecationWarning)
- self.assertIs(posixpath.ismount(b"/"), True)
+ self.assertIs(posixpath.ismount(b"/"), True)
def test_ismount_non_existent(self):
# Non-existent mountpoint.