|
1 | 1 | # -*- encoding: UTF-8
|
2 | 2 | from __future__ import unicode_literals
|
3 | 3 |
|
| 4 | +import os |
| 5 | +import stat |
| 6 | + |
4 | 7 | from six import text_type
|
5 | 8 |
|
6 | 9 | from fs.opener import open_fs
|
@@ -77,14 +80,24 @@ def test_getinfo(self):
|
77 | 80 | top = self.fs.getinfo("top.txt", ["details", "access"])
|
78 | 81 | self.assertEqual(top.size, 12)
|
79 | 82 | 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 | + |
82 | 93 | self.assertEqual(top.get("details", "type"), ResourceType.file)
|
83 | 94 |
|
84 | 95 | def test_listdir(self):
|
85 | 96 | self.assertEqual(
|
86 | 97 | sorted(self.source_fs.listdir("/")), sorted(self.fs.listdir("/"))
|
87 | 98 | )
|
| 99 | + for name in self.fs.listdir("/"): |
| 100 | + self.assertIsInstance(name, text_type) |
88 | 101 | with self.assertRaises(errors.DirectoryExpected):
|
89 | 102 | self.fs.listdir("top.txt")
|
90 | 103 | with self.assertRaises(errors.ResourceNotFound):
|
@@ -123,11 +136,3 @@ def test_walk_files(self):
|
123 | 136 | def test_implied_dir(self):
|
124 | 137 | self.fs.getinfo("foo/bar")
|
125 | 138 | 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