2 from pysize
.core
import chdir_browsing
4 LISTING
= set(['hardlink1_4', 'bad_dirname$)\x0c\x02\xb5AUg\xdf\xda',
5 'hardlink1_2', 'hardlink1_3', 'hardlink1_1', 'dir_symlink', 'hardlink3_1',
6 'hardlink3_2', 'fifo', 'UTF-8_dir_\xc3\xa9_\xc3\xa0', 'empty_dir',
7 'dangling_symlink', 'unreadable_file', 'hardlink2_1', 'to_point', 'hardlink2_3',
8 'hardlink2_2', 'file_symlink'])
10 class TestChdirBrowsing(unittest
.TestCase
):
11 def assertListing(self
, path
):
13 cookie
= chdir_browsing
.init(path
)
15 for child
in chdir_browsing
.listdir(cookie
):
18 chdir_browsing
.finalize(cookie
)
20 self
.assertEqual(listing
, LISTING
)
22 def testBrowsingOK(self
):
23 self
.assertListing('/tmp/pysize_example_dir')
25 def testBrowsingNoSuchPath(self
):
26 self
.assertRaises(OSError, chdir_browsing
.init
, '/no such/ path')
28 def testBrowsingBadFile(self
):
29 self
.assertRaises(OSError, chdir_browsing
.init
,
30 '/tmp/pysize_example_dir/unreadable_file')
32 def testBrowsingBadDir(self
):
33 self
.assertRaises(OSError, chdir_browsing
.init
,
34 '/tmp/pysize_example_dir/unreadable_dir')
36 def testBrowsingBadSymlink(self
):
37 self
.assertRaises(OSError, chdir_browsing
.init
,
38 '/tmp/pysize_example_dir/dangling_symlink')
40 def testBrowsingFileSymlink(self
):
41 self
.assertRaises(OSError, chdir_browsing
.init
,
42 '/tmp/pysize_example_dir/file_symlink')
44 def testBrowsingDirSymlink(self
):
45 self
.assertListing('/tmp/pysize_example_dir/to_point')
47 def testBrowsingDirSymlinkSlash(self
):
48 self
.assertListing('/tmp/pysize_example_dir/to_point/')
50 TESTS
= (TestChdirBrowsing
,)