diff options
author | Steve Dower <steve.dower@python.org> | 2019-08-21 20:43:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-21 20:43:06 (GMT) |
commit | 75e064962ee0e31ec19a8081e9d9cc957baf6415 (patch) | |
tree | eff4eb945f41439d4ad87a0786f3f519471601ea /Lib/unittest | |
parent | e1c638da6a065af6803028ced1afcc679e63f59d (diff) | |
download | cpython-75e064962ee0e31ec19a8081e9d9cc957baf6415.zip cpython-75e064962ee0e31ec19a8081e9d9cc957baf6415.tar.gz cpython-75e064962ee0e31ec19a8081e9d9cc957baf6415.tar.bz2 |
bpo-9949: Enable symlink traversal for ntpath.realpath (GH-15287)
Diffstat (limited to 'Lib/unittest')
-rw-r--r-- | Lib/unittest/test/test_discovery.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/unittest/test/test_discovery.py b/Lib/unittest/test/test_discovery.py index 204043b..16e081e 100644 --- a/Lib/unittest/test/test_discovery.py +++ b/Lib/unittest/test/test_discovery.py @@ -723,11 +723,13 @@ class TestDiscovery(unittest.TestCase): original_listdir = os.listdir original_isfile = os.path.isfile original_isdir = os.path.isdir + original_realpath = os.path.realpath def cleanup(): os.listdir = original_listdir os.path.isfile = original_isfile os.path.isdir = original_isdir + os.path.realpath = original_realpath del sys.modules['foo'] if full_path in sys.path: sys.path.remove(full_path) @@ -742,6 +744,10 @@ class TestDiscovery(unittest.TestCase): os.listdir = listdir os.path.isfile = isfile os.path.isdir = isdir + if os.name == 'nt': + # ntpath.realpath may inject path prefixes when failing to + # resolve real files, so we substitute abspath() here instead. + os.path.realpath = os.path.abspath return full_path def test_detect_module_clash(self): |