[Python-checkins] cpython: Add tests for Issue #10646.

brian.curtin python-checkins at python.org
Wed Dec 26 14:36:32 CET 2012


http://hg.python.org/cpython/rev/9e980454b85e
changeset:   81064:9e980454b85e
user:        Brian Curtin <brian at python.org>
date:        Wed Dec 26 07:36:16 2012 -0600
summary:
  Add tests for Issue #10646.

This issue is now fixed due to changes in Issue #11939, so I've refactored
the tests to cover the hard link case. There are no code changes here.

files:
  Lib/test/test_genericpath.py |  20 ++++++++++++++++----
  Misc/NEWS                    |   3 +++
  2 files changed, 19 insertions(+), 4 deletions(-)


diff --git a/Lib/test/test_genericpath.py b/Lib/test/test_genericpath.py
--- a/Lib/test/test_genericpath.py
+++ b/Lib/test/test_genericpath.py
@@ -205,13 +205,19 @@
             os.remove(test_fn)
 
     @support.skip_unless_symlink
-    def test_samefile_on_links(self):
+    def test_samefile_on_symlink(self):
+        self._test_samefile_on_link_func(os.symlink)
+
+    def test_samefile_on_link(self):
+        self._test_samefile_on_link_func(os.link)
+
+    def _test_samefile_on_link_func(self, func):
         try:
             test_fn1 = support.TESTFN + "1"
             test_fn2 = support.TESTFN + "2"
             self._create_file(test_fn1)
 
-            os.symlink(test_fn1, test_fn2)
+            func(test_fn1, test_fn2)
             self.assertTrue(self.pathmodule.samefile(test_fn1, test_fn2))
             os.remove(test_fn2)
 
@@ -232,13 +238,19 @@
             os.remove(test_fn)
 
     @support.skip_unless_symlink
-    def test_samestat_on_links(self):
+    def test_samestat_on_symlink(self):
+        self._test_samestat_on_link_func(os.symlink)
+
+    def test_samestat_on_link(self):
+        self._test_samestat_on_link_func(os.link)
+
+    def _test_samestat_on_link_func(self, func):
         try:
             test_fn1 = support.TESTFN + "1"
             test_fn2 = support.TESTFN + "2"
             self._create_file(test_fn1)
             test_fns = (test_fn1, test_fn2)
-            os.symlink(*test_fns)
+            func(*test_fns)
             stats = map(os.stat, test_fns)
             self.assertTrue(self.pathmodule.samestat(*stats))
             os.remove(test_fn2)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -516,6 +516,9 @@
 Tests
 -----
 
+- Issue #10646: Tests rearranged for os.samefile/samestat to check for not
+  just symlinks but also hard links.
+
 - Issue #16664: Add regression tests for glob's behaviour concerning entries
   starting with a ".".  Patch by Sebastian Kreft.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list