示例#1
0
def test_listfiles(tmpdir):
    tmpdir.join("file0").open("w")  # File in root directory
    sub0 = tmpdir.mkdir("sub0")  # Sub-directory with two files
    sub0.join("file0").open("w")
    sub0.join("file1").open("w")
    tmpdir.mkdir("sub1").join("file0").open("w")  # Sub-directory with one file
    tmpdir.mkdir("sub2")  # Sub-directory with no files
    expected = [
        "file0",
        os.path.join("sub0", "file0"),
        os.path.join("sub0", "file1"),
        os.path.join("sub1", "file0"),
    ]
    assert sorted(expected) == sorted(files.listfiles(str(tmpdir)))
示例#2
0
 def on_enter(self, text: str) -> None:
     """Update tag model on enter to include any new/deleted tags."""
     self.set_data(
         (f":{self._command} {api.completion.escape(fname)}",)
         for fname in files.listfiles(api.mark.tagdir)
     )
def test_listfiles(directory_tree):
    expected = sorted(directory_tree.files)
    assert expected == sorted(files.listfiles(str(directory_tree.root)))