Skip to content

Commit

Permalink
fix paths
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulinaPacyna committed Nov 5, 2023
1 parent f7a2c7c commit 1ba1213
Showing 1 changed file with 28 additions and 22 deletions.
50 changes: 28 additions & 22 deletions tests/test_command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

import pytest

NO_RETURN = "tests/cases/no_return.py"
MIXED_ARGS = "tests/cases/mixed_args.py"
NO_ARGS = "tests/cases/no_args.py"
NOT_A_FUNCTION = "tests/cases/not_a_function.py"
MIXED_ARGS_WITH_RETURN = "tests/cases/mixed_args_with_return.py"


def test_running_cli_version() -> None:
subprocess.run(["annotation_checker", "no_return.py"])
subprocess.run(["annotation_checker", NO_RETURN])


def test_exclude_files() -> None:
Expand All @@ -13,9 +19,9 @@ def test_exclude_files() -> None:
"annotation_checker",
"--strict=True",
r"--exclude_files=no_.*\.py",
"no_args.py",
"no_return.py",
"not_a_function.py",
NO_ARGS,
NO_RETURN,
NOT_A_FUNCTION,
],
capture_output=True,
universal_newlines=True,
Expand All @@ -26,11 +32,11 @@ def test_exclude_files() -> None:
@pytest.mark.parametrize(
"filename,result",
[
("mixed_args.py", 1),
("no_return.py", 1),
("no_args.py", 0),
("not_a_function.py", 0),
("mixed_args_with_return.py", 1),
(MIXED_ARGS, 1),
(NO_RETURN, 1),
(NO_ARGS, 0),
(NOT_A_FUNCTION, 0),
(MIXED_ARGS_WITH_RETURN, 1),
],
)
def test_exit_code(filename: str, result: int) -> None:
Expand All @@ -44,11 +50,11 @@ def test_exit_code(filename: str, result: int) -> None:

def test_logging_filepath() -> None:
process = subprocess.run(
["annotation_checker", "no_return.py"],
["annotation_checker", NO_RETURN],
capture_output=True,
universal_newlines=True,
)
assert "no_return.py" in process.stderr
assert NO_RETURN in process.stderr


@pytest.mark.parametrize(
Expand All @@ -63,7 +69,7 @@ def test_exclude_parameters(pattern: str, result: int) -> None:
[
"annotation_checker",
"--strict=True",
"mixed_args_with_return.py",
MIXED_ARGS_WITH_RETURN,
f"--exclude_parameters={pattern}",
],
capture_output=True,
Expand All @@ -75,15 +81,15 @@ def test_exclude_parameters(pattern: str, result: int) -> None:
@pytest.mark.parametrize(
"input_,pattern,result",
[
("mixed_args.py", "", 1),
("no_return.py", "", 1),
("mixed_args_with_return.py", "", 1),
("mixed_args.py", "dgag", 1),
("no_return.py", "adsg", 1),
("mixed_args_with_return.py", "agddfa", 1),
("mixed_args.py", "^f", 0),
("no_return.py", "^f", 0),
("mixed_args_with_return.py", "^f", 0),
(MIXED_ARGS, "", 1),
(NO_RETURN, "", 1),
(MIXED_ARGS_WITH_RETURN, "", 1),
(MIXED_ARGS, "dgag", 1),
(NO_RETURN, "adsg", 1),
(MIXED_ARGS_WITH_RETURN, "agddfa", 1),
(MIXED_ARGS, "^f", 0),
(NO_RETURN, "^f", 0),
(MIXED_ARGS_WITH_RETURN, "^f", 0),
],
)
def test_exclude_by_name(input_: str, pattern: str, result: int) -> None:
Expand All @@ -103,7 +109,7 @@ def test_exclude_by_name(input_: str, pattern: str, result: int) -> None:

def test_debug_level():
process = subprocess.run(
["annotation_checker", "no_return.py", "--log-level=DEBUG"],
["annotation_checker", NO_RETURN, "--log-level=DEBUG"],
capture_output=True,
universal_newlines=True,
)
Expand Down

0 comments on commit 1ba1213

Please sign in to comment.