示例#1
0
 def test_walk(self):
     walk = []
     for path, dirs, files in self.fs.walk():
         walk.append(
             (path, [info.name
                     for info in dirs], [info.name for info in files]))
     expected = [(u'/', [u'foo1', u'foo2', u'foo3'], []),
                 (u'/foo1', [u'bar1'], [u'top1.txt', u'top2.txt']),
                 (u'/foo2', [u'bar2'], [u'top3.txt']), (u'/foo3', [], []),
                 (u'/foo1/bar1', [], []), (u'/foo2/bar2', [u'bar3'], []),
                 (u'/foo2/bar2/bar3', [], [u'test.txt'])]
     self.assertEqual(walk, expected)
示例#2
0
 def test_walk_info(self):
     walk = []
     for path, info in self.fs.walk.info():
         walk.append((path, info.is_dir, info.name))
     expected = [(u'/foo1', True, u'foo1'), (u'/foo2', True, u'foo2'),
                 (u'/foo3', True, u'foo3'), (u'/foo1/bar1', True, u'bar1'),
                 (u'/foo1/top1.txt', False, u'top1.txt'),
                 (u'/foo1/top2.txt', False, u'top2.txt'),
                 (u'/foo2/bar2', True, u'bar2'),
                 (u'/foo2/top3.txt', False, u'top3.txt'),
                 (u'/foo2/bar2/bar3', True, u'bar3'),
                 (u'/foo2/bar2/bar3/test.txt', False, u'test.txt')]
     self.assertEqual(walk, expected)
示例#3
0
    def test_walk_info(self):
        walk = []
        for path, info in self.fs.walk.info():
            walk.append((path, info.is_dir, info.name))

        expected = [
            ("/foo1", True, "foo1"),
            ("/foo2", True, "foo2"),
            ("/foo3", True, "foo3"),
            ("/foo1/top1.txt", False, "top1.txt"),
            ("/foo1/top2.txt", False, "top2.txt"),
            ("/foo1/bar1", True, "bar1"),
            ("/foo2/bar2", True, "bar2"),
            ("/foo2/top3.bin", False, "top3.bin"),
            ("/foo2/bar2/bar3", True, "bar3"),
            ("/foo2/bar2/bar3/test.txt", False, "test.txt"),
        ]
        self.assertEqual(walk, expected)