Skip to content

Commit

Permalink
Test coverage of branching.
Browse files Browse the repository at this point in the history
Also test coverage of test code.
  • Loading branch information
udifuchs committed Oct 19, 2024
1 parent 0674a62 commit f324152
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pylint_silent/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ def main() -> int:
return 1 # pragma: no cover


if __name__ == "__main__":
if __name__ == "__main__": # pragma: no cover
sys.exit(main())
13 changes: 12 additions & 1 deletion tests/test_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def run_pylint_silent(*args: str) -> Union[int, str, None]:
runpy.run_module("pylint_silent", run_name="__main__")
except SystemExit as ex:
return ex.code
return None
raise RuntimeError # pragma: no cover # pylint_silent alway raises SystemExit


# pylint: disable-next=too-few-public-methods,too-many-instance-attributes; silent
Expand Down Expand Up @@ -131,6 +131,17 @@ def test_apply(ctx: Context) -> None:
assert exitcode == 0


def test_apply_empty(ctx: Context) -> None:
"""Test 'pylint-silent apply' with empty file."""
pylint_output = ctx.temp_sample_filename + "lint-empty"
# Create empty file:
with open(pylint_output, "w", encoding="utf-8"):
pass

# Apply pylint-silent changed based on empty file:
run_pylint_silent("apply", pylint_output)


def test_apply_signature(ctx: Context) -> None:
"""Test 'pylint-silent apply'."""
# Run pylint on test files.
Expand Down
5 changes: 4 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,13 @@ deps =
coverage

commands =
coverage run -m --source=pylint_silent pytest tests
coverage run -m pytest tests
coverage html
coverage report --show-missing --fail-under=100

[coverage:run]
branch = True

[pycodestyle]
# Line length of 88 copied from black.
max-line-length = 88
Expand Down

0 comments on commit f324152

Please sign in to comment.