Commit 262df4d3 authored by Christian Heimes's avatar Christian Heimes

Solaris' /dev/null is a symlink. The device test now uses stat instead of lstat to compensate

for symlinks.
parent 4807df41
...@@ -58,8 +58,12 @@ class TestFilemode(unittest.TestCase): ...@@ -58,8 +58,12 @@ class TestFilemode(unittest.TestCase):
pass pass
tearDown = setUp tearDown = setUp
def get_mode(self, fname=TESTFN): def get_mode(self, fname=TESTFN, lstat=True):
return os.lstat(fname).st_mode if lstat:
st_mode = os.lstat(fname).st_mode
else:
st_mode = os.stat(fname).st_mode
return st_mode
def assertS_IS(self, name, mode): def assertS_IS(self, name, mode):
# test format, lstrip is for S_IFIFO # test format, lstrip is for S_IFIFO
...@@ -136,12 +140,12 @@ class TestFilemode(unittest.TestCase): ...@@ -136,12 +140,12 @@ class TestFilemode(unittest.TestCase):
@unittest.skipUnless(os.name == 'posix', 'requires Posix') @unittest.skipUnless(os.name == 'posix', 'requires Posix')
def test_devices(self): def test_devices(self):
if os.path.exists(os.devnull): if os.path.exists(os.devnull):
st_mode = self.get_mode(os.devnull) st_mode = self.get_mode(os.devnull, lstat=False)
self.assertS_IS("CHR", st_mode) self.assertS_IS("CHR", st_mode)
# Linux block devices, BSD has no block devices anymore # Linux block devices, BSD has no block devices anymore
for blockdev in ("/dev/sda", "/dev/hda"): for blockdev in ("/dev/sda", "/dev/hda"):
if os.path.exists(blockdev): if os.path.exists(blockdev):
st_mode = self.get_mode(blockdev) st_mode = self.get_mode(blockdev, lstat=False)
self.assertS_IS("BLK", st_mode) self.assertS_IS("BLK", st_mode)
break break
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment