diff options
author | Brian Curtin <brian@python.org> | 2011-06-13 21:03:01 (GMT) |
---|---|---|
committer | Brian Curtin <brian@python.org> | 2011-06-13 21:03:01 (GMT) |
commit | c9d6a501db51db3038995aa014624f83e860ef63 (patch) | |
tree | 63c24f12abb94fce424b0666dae5cafe8e11b0ef /Lib | |
parent | 415007e30dceced68b2c7d3a19143f0a3737fed7 (diff) | |
parent | 3e86c99f9080633283e415f3bd4653285e24c31e (diff) | |
download | cpython-c9d6a501db51db3038995aa014624f83e860ef63.zip cpython-c9d6a501db51db3038995aa014624f83e860ef63.tar.gz cpython-c9d6a501db51db3038995aa014624f83e860ef63.tar.bz2 |
branch merge
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/support.py | 2 | ||||
-rw-r--r-- | Lib/test/test_os.py | 45 |
2 files changed, 46 insertions, 1 deletions
diff --git a/Lib/test/support.py b/Lib/test/support.py index f5dbb85..a51d943 100644 --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -1561,7 +1561,7 @@ def can_symlink(): try: os.symlink(TESTFN, symlink_path) can = True - except (OSError, NotImplementedError): + except (OSError, NotImplementedError, AttributeError): can = False else: os.remove(symlink_path) diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 82a29fe..13dc337 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -1248,6 +1248,51 @@ class Win32SymlinkTests(unittest.TestCase): self.assertEqual(os.stat(link), os.stat(target)) self.assertNotEqual(os.lstat(link), os.stat(link)) + bytes_link = os.fsencode(link) + self.assertEqual(os.stat(bytes_link), os.stat(target)) + self.assertNotEqual(os.lstat(bytes_link), os.stat(bytes_link)) + + def test_12084(self): + level1 = os.path.abspath(support.TESTFN) + level2 = os.path.join(level1, "level2") + level3 = os.path.join(level2, "level3") + try: + os.mkdir(level1) + os.mkdir(level2) + os.mkdir(level3) + + file1 = os.path.abspath(os.path.join(level1, "file1")) + + with open(file1, "w") as f: + f.write("file1") + + orig_dir = os.getcwd() + try: + os.chdir(level2) + link = os.path.join(level2, "link") + os.symlink(os.path.relpath(file1), "link") + self.assertIn("link", os.listdir(os.getcwd())) + + # Check os.stat calls from the same dir as the link + self.assertEqual(os.stat(file1), os.stat("link")) + + # Check os.stat calls from a dir below the link + os.chdir(level1) + self.assertEqual(os.stat(file1), + os.stat(os.path.relpath(link))) + + # Check os.stat calls from a dir above the link + os.chdir(level3) + self.assertEqual(os.stat(file1), + os.stat(os.path.relpath(link))) + finally: + os.chdir(orig_dir) + except OSError as err: + self.fail(err) + finally: + os.remove(file1) + shutil.rmtree(level1) + class FSEncodingTests(unittest.TestCase): def test_nop(self): |