Esempio n. 1
0
def test_circular_symlink(tmp_path: Path):

    (tmp_path / "a-symlink").symlink_to(tmp_path)

    paths = index(tmp_path)

    assert_same_index(paths, {".", "a-symlink"})
Esempio n. 2
0
def test_file_path(tmp_path: Path):

    (tmp_path / "file.ext").touch()

    assert_same_index(index(tmp_path / "file.ext", absolute=True),
                      {tmp_path / "file.ext"})

    assert_same_index(index(tmp_path / "file.ext", absolute=False), {"."})
Esempio n. 3
0
def test_empty(tmp_path: Path):

    (tmp_path / "source").mkdir()
    (tmp_path / "target").mkdir()

    merge(tmp_path / "source", tmp_path / "target")

    assert_same_index(index(tmp_path / "target"), {"."})
Esempio n. 4
0
def test_order(tmp_path: Path):

    (tmp_path / "dir1").mkdir()
    (tmp_path / "dir1/dir2").mkdir()
    (tmp_path / "dir1/dir2/file").touch()

    assert_same_index(index(tmp_path, order=Order.PRE), [
        ".",
        "dir1",
        "dir1/dir2",
        "dir1/dir2/file",
    ])

    assert_same_index(index(tmp_path, order=Order.POST), [
        "dir1/dir2/file",
        "dir1/dir2",
        "dir1",
        ".",
    ])
Esempio n. 5
0
def test_simple(tmp_path: Path):

    (tmp_path / "dir1").mkdir()
    (tmp_path / "dir2").mkdir()
    (tmp_path / "dir2/dir3").mkdir()
    (tmp_path / "file1").touch()
    (tmp_path / "dir1/file2").touch()
    (tmp_path / "dir2/dir3/file3").touch()

    paths = index(tmp_path, order=Order.PRE)

    assert_same_index(
        paths, {
            ".",
            'dir1',
            'dir1/file2',
            'dir2',
            'dir2/dir3',
            'dir2/dir3/file3',
            'file1',
        })
Esempio n. 6
0
def test_no_collisions(tmp_path: Path):

    (tmp_path / "source").mkdir()
    (tmp_path / "source/file1").touch()
    (tmp_path / "source/dir1").mkdir()
    (tmp_path / "source/dir1/file2").touch()

    (tmp_path / "target").mkdir()
    (tmp_path / "target/file3").touch()
    (tmp_path / "target/dir1").mkdir()
    (tmp_path / "target/dir1/file4").touch()

    merge(tmp_path / "source", tmp_path / "target")

    assert_same_index(index(tmp_path / "target"), {
        ".",
        "file1",
        "file3",
        "dir1",
        "dir1/file2",
        "dir1/file4",
    })
Esempio n. 7
0
def test_empty(tmp_path: Path):

    paths = index(tmp_path)

    assert_same_index(paths, {"."})
Esempio n. 8
0
def test_root_exclusion(tmp_path: Path):

    (tmp_path / "some-dir").mkdir()

    assert_same_index(index(tmp_path / "some-dir", include_root=False), set())
    assert_same_index(index(tmp_path / "some-dir", include_root=True), {"."})