Exemplo n.º 1
0
def test_iterchildren_no_exclusions(tmp_pathplus: PathPlus):
    (tmp_pathplus / ".git").mkdir()
    (tmp_pathplus / "venv").mkdir()
    (tmp_pathplus / ".venv").mkdir()
    (tmp_pathplus / ".tox").mkdir()
    (tmp_pathplus / ".tox4").mkdir()
    (tmp_pathplus / ".mypy_cache").mkdir()
    (tmp_pathplus / ".pytest_cache").mkdir()
    (tmp_pathplus / "normal_dir").mkdir()

    children = sorted(
        p.relative_to(tmp_pathplus) for p in tmp_pathplus.iterchildren(None))
    assert children == [
        PathPlus(".git"),
        PathPlus(".mypy_cache"),
        PathPlus(".pytest_cache"),
        PathPlus(".tox"),
        PathPlus(".tox4"),
        PathPlus(".venv"),
        PathPlus("normal_dir"),
        PathPlus("venv"),
    ]

    children = sorted(
        p.relative_to(tmp_pathplus) for p in tmp_pathplus.iterchildren(()))
    assert children == [
        PathPlus(".git"),
        PathPlus(".mypy_cache"),
        PathPlus(".pytest_cache"),
        PathPlus(".tox"),
        PathPlus(".tox4"),
        PathPlus(".venv"),
        PathPlus("normal_dir"),
        PathPlus("venv"),
    ]

    children = sorted(
        p.relative_to(tmp_pathplus)
        for p in tmp_pathplus.iterchildren((".git", ".tox")))
    assert children == [
        PathPlus(".mypy_cache"),
        PathPlus(".pytest_cache"),
        PathPlus(".tox4"),
        PathPlus(".venv"),
        PathPlus("normal_dir"),
        PathPlus("venv"),
    ]

    children = sorted(
        p.relative_to(tmp_pathplus) for p in tmp_pathplus.iterchildren())
    assert children == [
        PathPlus("normal_dir"),
    ]
Exemplo n.º 2
0
def test_iterchildren_match(
        advanced_data_regression: AdvancedDataRegressionFixture,
        absolute: bool):
    repo_path = PathPlus(__file__).parent.parent
    with in_directory(repo_path.parent):

        assert repo_path.is_dir()

        if not absolute:
            repo_path = repo_path.relative_to(repo_path.parent)

        if (repo_path / "build").is_dir():
            shutil.rmtree(repo_path / "build")

        children = list(repo_path.iterchildren(match="**/*.py"))
        assert children

        child_paths = sorted(
            p.relative_to(repo_path).as_posix() for p in children)

        for exclude_filename in {
                ".coverage", "pathtype_demo.py", "dist", "htmlcov", "conda",
                ".idea", "mutdef.py"
        }:
            if exclude_filename in child_paths:
                child_paths.remove(exclude_filename)

        advanced_data_regression.check(child_paths,
                                       basename="test_iterchildren_match")
Exemplo n.º 3
0
def test_iterchildren_exclusions():
    repo_path = PathPlus(__file__).parent.parent
    assert repo_path.is_dir()

    if (repo_path / "build").is_dir():
        shutil.rmtree(repo_path / "build")

    children = list(repo_path.iterchildren())
    assert children
    for directory in children:
        directory = directory.relative_to(repo_path)
        # print(directory)
        assert directory.parts[0] not in paths.unwanted_dirs