コード例 #1
0
 def test_hidden_dir(self):
     child = mkdtemp(dir=self.root, prefix=".")
     fd, name = mkstemp(dir=child)
     os.close(fd)
     assert list(iter_paths(child)) == []
     assert list(iter_paths(child, skip_hidden=False)) == [name]
     assert list(iter_paths(self.root)) == []
     assert list(iter_paths(self.root, skip_hidden=False)) == [name]
コード例 #2
0
 def test_one_file_exclude(self):
     fd, name = mkstemp(dir=self.root)
     os.close(fd)
     assert list(iter_paths(self.root, exclude=[self.root])) == []
     assert list(iter_paths(self.root,
                            exclude=[os.path.dirname(self.root)])) == []
     assert list(iter_paths(self.root, exclude=[name])) == []
     assert list(iter_paths(self.root, exclude=[name + "a"])) == [name]
コード例 #3
0
    def test_with_file(self):
        fd, name = mkstemp(dir=self.root)
        os.close(fd)
        link = os.path.join(self.root, "foo")
        os.symlink(name, link)

        assert list(iter_paths(self.root)) == [name, name]
        assert list(iter_paths(self.root, exclude=[link])) == [name]
        assert list(iter_paths(self.root, exclude=[name])) == []
コード例 #4
0
    def test_with_dir_symlink(self):
        child = mkdtemp(dir=self.root)
        link = os.path.join(self.root, "foo")
        os.symlink(child, link)
        fd, name = mkstemp(dir=link)
        os.close(fd)

        assert name not in list(iter_paths(self.root))
        assert list(iter_paths(link)) == list(iter_paths(child))

        assert list(iter_paths(link, exclude=[link])) == []
        assert list(iter_paths(child, exclude=[child])) == []
        assert list(iter_paths(link, exclude=[child])) == []
コード例 #5
0
    def test_hidden_file(self):
        fd, name = mkstemp(dir=self.root, prefix=".")
        os.close(fd)

        assert list(iter_paths(self.root)) == []
コード例 #6
0
 def test_one_file(self):
     fd, name = mkstemp(dir=self.root)
     os.close(fd)
     assert list(iter_paths(self.root)) == [name]
コード例 #7
0
 def test_empty(self):
     assert list(iter_paths(self.root)) == []