Skip to content

Commit 36a7e4f

Browse files
committed
Solaris' /dev/null is a symlink. The device test now uses stat instead of lstat to compensate
for symlinks.
1 parent 9ee0203 commit 36a7e4f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Lib/test/test_stat.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,11 @@ def setUp(self):
5858
pass
5959
tearDown = setUp
6060

61-
def get_mode(self, fname=TESTFN):
62-
st_mode = os.lstat(fname).st_mode
61+
def get_mode(self, fname=TESTFN, lstat=True):
62+
if lstat:
63+
st_mode = os.lstat(fname).st_mode
64+
else:
65+
st_mode = os.stat(fname).st_mode
6366
modestr = stat.filemode(st_mode)
6467
return st_mode, modestr
6568

@@ -149,13 +152,13 @@ def test_fifo(self):
149152
@unittest.skipUnless(os.name == 'posix', 'requires Posix')
150153
def test_devices(self):
151154
if os.path.exists(os.devnull):
152-
st_mode, modestr = self.get_mode(os.devnull)
155+
st_mode, modestr = self.get_mode(os.devnull, lstat=False)
153156
self.assertEqual(modestr[0], 'c')
154157
self.assertS_IS("CHR", st_mode)
155158
# Linux block devices, BSD has no block devices anymore
156159
for blockdev in ("/dev/sda", "/dev/hda"):
157160
if os.path.exists(blockdev):
158-
st_mode, modestr = self.get_mode(blockdev)
161+
st_mode, modestr = self.get_mode(blockdev, lstat=False)
159162
self.assertEqual(modestr[0], 'b')
160163
self.assertS_IS("BLK", st_mode)
161164
break

0 commit comments

Comments
 (0)