]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Solaris' /dev/null is a symlink. The device test now uses stat instead of lstat to...
authorChristian Heimes <christian@cheimes.de>
Sun, 23 Jun 2013 14:10:29 +0000 (16:10 +0200)
committerChristian Heimes <christian@cheimes.de>
Sun, 23 Jun 2013 14:10:29 +0000 (16:10 +0200)
for symlinks.

Lib/test/test_stat.py

index 8de5f360c44812ec950d0e92bc3a28d4442e87ce..eb3f07a63d337d30958c22ae068116e25a08ece5 100644 (file)
@@ -58,8 +58,11 @@ class TestFilemode(unittest.TestCase):
                 pass
     tearDown = setUp
 
-    def get_mode(self, fname=TESTFN):
-        st_mode = os.lstat(fname).st_mode
+    def get_mode(self, fname=TESTFN, lstat=True):
+        if lstat:
+            st_mode = os.lstat(fname).st_mode
+        else:
+            st_mode = os.stat(fname).st_mode
         modestr = stat.filemode(st_mode)
         return st_mode, modestr
 
@@ -149,13 +152,13 @@ class TestFilemode(unittest.TestCase):
     @unittest.skipUnless(os.name == 'posix', 'requires Posix')
     def test_devices(self):
         if os.path.exists(os.devnull):
-            st_mode, modestr = self.get_mode(os.devnull)
+            st_mode, modestr = self.get_mode(os.devnull, lstat=False)
             self.assertEqual(modestr[0], 'c')
             self.assertS_IS("CHR", st_mode)
         # Linux block devices, BSD has no block devices anymore
         for blockdev in ("/dev/sda", "/dev/hda"):
             if os.path.exists(blockdev):
-                st_mode, modestr = self.get_mode(blockdev)
+                st_mode, modestr = self.get_mode(blockdev, lstat=False)
                 self.assertEqual(modestr[0], 'b')
                 self.assertS_IS("BLK", st_mode)
                 break