Skip to content

Commit 4465493

Browse files
authored
fix permissions test fail in archive (#244)
1 parent 6ba8e5d commit 4465493

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

tests/test_archives.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# -*- encoding: UTF-8
22
from __future__ import unicode_literals
33

4+
import os
5+
import stat
6+
47
from six import text_type
58

69
from fs.opener import open_fs
@@ -77,14 +80,24 @@ def test_getinfo(self):
7780
top = self.fs.getinfo("top.txt", ["details", "access"])
7881
self.assertEqual(top.size, 12)
7982
self.assertFalse(top.is_dir)
80-
if not isinstance(self.source_fs, MemoryFS):
81-
self.assertEqual(top.permissions.mode, 0o644)
83+
84+
try:
85+
source_syspath = self.source_fs.getsyspath("/top.txt")
86+
except errors.NoSysPath:
87+
pass
88+
else:
89+
self.assertEqual(
90+
top.permissions.mode, stat.S_IMODE(os.stat(source_syspath).st_mode)
91+
)
92+
8293
self.assertEqual(top.get("details", "type"), ResourceType.file)
8394

8495
def test_listdir(self):
8596
self.assertEqual(
8697
sorted(self.source_fs.listdir("/")), sorted(self.fs.listdir("/"))
8798
)
99+
for name in self.fs.listdir("/"):
100+
self.assertIsInstance(name, text_type)
88101
with self.assertRaises(errors.DirectoryExpected):
89102
self.fs.listdir("top.txt")
90103
with self.assertRaises(errors.ResourceNotFound):
@@ -123,11 +136,3 @@ def test_walk_files(self):
123136
def test_implied_dir(self):
124137
self.fs.getinfo("foo/bar")
125138
self.fs.getinfo("foo")
126-
127-
def test_listdir(self):
128-
for name in self.fs.listdir("/"):
129-
self.assertIsInstance(name, text_type)
130-
with self.assertRaises(errors.ResourceNotFound):
131-
self.fs.listdir("nope")
132-
with self.assertRaises(errors.DirectoryExpected):
133-
self.fs.listdir("top.txt")

0 commit comments

Comments
 (0)