summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2016-08-19 01:27:48 (GMT)
committerR David Murray <rdmurray@bitdance.com>2016-08-19 01:27:48 (GMT)
commit750018b91aeb5dfb46dc1e156a8b4e7aefb6d59f (patch)
tree0a2b261890a8139d6598e8e0b43dc60ae80d0302 /Lib/test
parenteec9331b207cf7def6f04156d00a8479d1630dd3 (diff)
downloadcpython-750018b91aeb5dfb46dc1e156a8b4e7aefb6d59f.zip
cpython-750018b91aeb5dfb46dc1e156a8b4e7aefb6d59f.tar.gz
cpython-750018b91aeb5dfb46dc1e156a8b4e7aefb6d59f.tar.bz2
#2466: ismount now recognizes mount points user can't access.
Patch by Robin Roth, reviewed by Serhiy Storchaka, comment wording tweaked by me.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_posixpath.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py
index acf1102..0783c36 100644
--- a/Lib/test/test_posixpath.py
+++ b/Lib/test/test_posixpath.py
@@ -1,7 +1,5 @@
-import itertools
import os
import posixpath
-import sys
import unittest
import warnings
from posixpath import realpath, abspath, dirname, basename
@@ -213,6 +211,28 @@ class PosixPathTest(unittest.TestCase):
finally:
os.lstat = save_lstat
+ @unittest.skipIf(posix is None, "Test requires posix module")
+ def test_ismount_directory_not_readable(self):
+ # issue #2466: Simulate ismount run on a directory that is not
+ # readable, which used to return False.
+ save_lstat = os.lstat
+ def fake_lstat(path):
+ st_ino = 0
+ st_dev = 0
+ if path.startswith(ABSTFN) and path != ABSTFN:
+ # ismount tries to read something inside the ABSTFN directory;
+ # simulate this being forbidden (no read permission).
+ raise OSError("Fake [Errno 13] Permission denied")
+ if path == ABSTFN:
+ st_dev = 1
+ st_ino = 1
+ return posix.stat_result((0, st_ino, st_dev, 0, 0, 0, 0, 0, 0, 0))
+ try:
+ os.lstat = fake_lstat
+ self.assertIs(posixpath.ismount(ABSTFN), True)
+ finally:
+ os.lstat = save_lstat
+
def test_expanduser(self):
self.assertEqual(posixpath.expanduser("foo"), "foo")
self.assertEqual(posixpath.expanduser(b"foo"), b"foo")