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]
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]
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])) == []
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])) == []
def test_hidden_file(self): fd, name = mkstemp(dir=self.root, prefix=".") os.close(fd) assert list(iter_paths(self.root)) == []
def test_one_file(self): fd, name = mkstemp(dir=self.root) os.close(fd) assert list(iter_paths(self.root)) == [name]
def test_empty(self): assert list(iter_paths(self.root)) == []