Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General improvements in the testing suite #60

Merged
merged 2 commits into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Empty file added tests/data/paths/a.py
Empty file.
Empty file added tests/data/paths/b.c
Empty file.
Empty file added tests/data/paths/dir/git/git.py
Empty file.
Empty file added tests/data/paths/dir/i.c
Empty file.
1 change: 1 addition & 0 deletions tests/data/paths/dir/r.py
Empty file added tests/data/paths/dir/s.py
Empty file.
Empty file added tests/data/paths/dir/u.py
Empty file.
Empty file added tests/data/paths/dir/utils/r.py
Empty file.
Empty file added tests/data/paths/dir/x.py
Empty file.
Empty file added tests/data/paths/dir/y.py
Empty file.
Empty file added tests/data/paths/dir/z.py
Empty file.
27 changes: 11 additions & 16 deletions tests/test_pathu.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@
from pycln.utils import pathu, regexu
from pycln.utils.report import Report

from . import CONFIG_DIR

# Constants.
MOCK = "pycln.utils.report.%s"
THIS_DIR = Path(__file__).parent
DATA_DIR = Path(__file__).parent.joinpath("data")

if ISWIN:
PYVER = "Lib"
Expand All @@ -32,30 +30,27 @@ class TestPathu:
"path, include, exclude, gitignore, expec",
[
pytest.param(
Path(__file__).parent.parent,
re.compile(r"test_.*\.py$"),
re.compile(r"(.*_re.*\.py|.*s\.py|.git/|pycln/)$"),
Path(DATA_DIR / "paths" / "dir"),
re.compile(r".*\.py$"),
re.compile(r"(.*s\.py|git/)$"),
PathSpec.from_lines("gitwildmatch", ["*u.py", "utils/"]),
{
"test_main.py",
"test_scan.py",
"test_config.py",
"test_metadata.py",
"test_transform.py",
"test_cli.py",
"x.py",
"y.py",
"z.py",
},
id="path: directory",
),
pytest.param(
Path(__file__),
Path(DATA_DIR / "paths" / "a.py"),
re.compile(r".*\.py$"),
re.compile(r""),
PathSpec.from_lines("gitwildmatch", []),
{"test_pathu.py"},
{"a.py"},
id="path: file",
),
pytest.param(
CONFIG_DIR.joinpath("setup.cfg"),
Path(DATA_DIR / "paths" / "b.c"),
re.compile(r".*\.py$"),
re.compile(r""),
PathSpec.from_lines("gitwildmatch", []),
Expand All @@ -74,7 +69,7 @@ def test_yield_sources(

@mock.patch(MOCK % "Report.ignored_path")
def test_nested_gitignore(self, ignored_path):
path = Path(THIS_DIR / "data" / "nested_gitignore_tests")
path = Path(DATA_DIR / "nested_gitignore_tests")
include = regexu.safe_compile(regexu.INCLUDE_REGEX, regexu.INCLUDE)
exclude = regexu.safe_compile(regexu.EXCLUDE_REGEX, regexu.EXCLUDE)
gitignore = regexu.get_gitignore(path)
Expand Down