diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2013-05-27 23:26:36 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2013-05-27 23:26:36 -0400 |
commit | 8f1a8e32b101ce365147b30c0feb3f31a14a60b6 (patch) | |
tree | 48ca95ddc0f44bdd67e14e2e221debfec5ebf511 /Lib | |
parent | 667a03b292e881f1ab0d0dba181868200d2abaf9 (diff) | |
parent | 3a09286790c58522195eadc3eaa4a21e8da89ea1 (diff) | |
download | cpython-git-8f1a8e32b101ce365147b30c0feb3f31a14a60b6.tar.gz |
Merge with 3.3
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_os.py | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 65d3c3bf6e..8b445b23b1 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -686,13 +686,8 @@ class WalkTests(unittest.TestCase): f.write("I'm " + path + " and proud of it. Blame test_os.\n") f.close() if support.can_symlink(): - if os.name == 'nt': - def symlink_to_dir(src, dest): - os.symlink(src, dest, True) - else: - symlink_to_dir = os.symlink - symlink_to_dir(os.path.abspath(t2_path), link_path) - symlink_to_dir('broken', broken_link_path) + os.symlink(os.path.abspath(t2_path), link_path) + symlink_to_dir('broken', broken_link_path, True) sub2_tree = (sub2_path, ["link"], ["broken_link", "tmp3"]) else: sub2_tree = (sub2_path, [], ["tmp3"]) @@ -1516,7 +1511,7 @@ class Win32SymlinkTests(unittest.TestCase): os.remove(self.missing_link) def test_directory_link(self): - os.symlink(self.dirlink_target, self.dirlink, True) + os.symlink(self.dirlink_target, self.dirlink) self.assertTrue(os.path.exists(self.dirlink)) self.assertTrue(os.path.isdir(self.dirlink)) self.assertTrue(os.path.islink(self.dirlink)) @@ -1610,6 +1605,38 @@ class Win32SymlinkTests(unittest.TestCase): shutil.rmtree(level1) +@support.skip_unless_symlink +class NonLocalSymlinkTests(unittest.TestCase): + + def setUp(self): + """ + Create this structure: + + base + \___ some_dir + """ + os.makedirs('base/some_dir') + + def tearDown(self): + shutil.rmtree('base') + + def test_directory_link_nonlocal(self): + """ + The symlink target should resolve relative to the link, not relative + to the current directory. + + Then, link base/some_link -> base/some_dir and ensure that some_link + is resolved as a directory. + + In issue13772, it was discovered that directory detection failed if + the symlink target was not specified relative to the current + directory, which was a defect in the implementation. + """ + src = os.path.join('base', 'some_link') + os.symlink('some_dir', src) + assert os.path.isdir(src) + + class FSEncodingTests(unittest.TestCase): def test_nop(self): self.assertEqual(os.fsencode(b'abc\xff'), b'abc\xff') @@ -2243,6 +2270,7 @@ def test_main(): Pep383Tests, Win32KillTests, Win32SymlinkTests, + NonLocalSymlinkTests, FSEncodingTests, DeviceEncodingTests, PidTests, |