summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorBrian Curtin <brian.curtin@gmail.com>2010-11-24 20:24:31 (GMT)
committerBrian Curtin <brian.curtin@gmail.com>2010-11-24 20:24:31 (GMT)
commit1b9df3962088142300728724c485425a93eb5f2a (patch)
tree39ab274a95dec2ba74005f8baee2ba6354525aa5 /Lib/test
parentf21c7ed39d026fea90d87a82290e677c6b4c5002 (diff)
downloadcpython-1b9df3962088142300728724c485425a93eb5f2a.zip
cpython-1b9df3962088142300728724c485425a93eb5f2a.tar.gz
cpython-1b9df3962088142300728724c485425a93eb5f2a.tar.bz2
Fix #8879. Add os.link support to Windows.
Additionally, the st_ino attribute of stat structures was not being filled in. This was left out of the fix to #10027 and was noticed due to test_tarfile failing when applying the patch for this issue. An earlier version of the fix to #10027 included st_ino, but that attribute got lost in the shuffle of a few review/fix cycles. All tests pass.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_os.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 129367e..978364c 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -860,6 +860,33 @@ class TestInvalidFD(unittest.TestCase):
if hasattr(os, "write"):
self.check(os.write, b" ")
+
+class LinkTests(unittest.TestCase):
+ def setUp(self):
+ self.file1 = support.TESTFN
+ self.file2 = os.path.join(support.TESTFN + "2")
+
+ for file in (self.file1, self.file2):
+ if os.path.exists(file):
+ os.unlink(file)
+
+ tearDown = setUp
+
+ def _test_link(self, file1, file2):
+ with open(file1, "w") as f1:
+ f1.write("test")
+
+ os.link(file1, file2)
+ with open(file1, "r") as f1, open(file2, "r") as f2:
+ self.assertTrue(os.path.sameopenfile(f1.fileno(), f2.fileno()))
+
+ def test_link(self):
+ self._test_link(self.file1, self.file2)
+
+ def test_link_bytes(self):
+ self._test_link(bytes(self.file1, sys.getfilesystemencoding()),
+ bytes(self.file2, sys.getfilesystemencoding()))
+
if sys.platform != 'win32':
class Win32ErrorTests(unittest.TestCase):
pass
@@ -1221,6 +1248,7 @@ def test_main():
FSEncodingTests,
PidTests,
LoginTests,
+ LinkTests,
)
if __name__ == "__main__":