Skip to content

Commit

Permalink
Add test coverage (#148)
Browse files Browse the repository at this point in the history
Co-authored-by: Sorin Sbarnea <sorin.sbarnea@gmail.com>
  • Loading branch information
ziegenberg and ssbarnea committed Nov 18, 2021
1 parent 5c57b65 commit 3be927a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[run]
omit = tests/*

[html]
directory = coverage_html_report
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ dist
*.egg*
README.pdf
.tox
coverage_html_report
.coverage
docs/source/_build
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ docs =
Sphinx
setuptools_scm
sphinx_rtd_theme
test =
pytest
pytest-cov

[flake8]
format = pylint
Expand Down
16 changes: 16 additions & 0 deletions tests/test_ansi2html.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,22 @@ def test_partial_as_command(
assert isinstance(expected, str)
assert expected == html

@patch("sys.argv", new_callable=lambda: ["ansi2html", "--headers"])
@patch("sys.stdout", new_callable=StringIO)
def test_headers_as_command(
self, mock_stdout: StringIO, mock_argv: List[str]
) -> None:

main()

with open(join(_here, "produce_headers.txt"), "rb") as produce_headers:
expected = read_to_unicode(produce_headers)

html = mock_stdout.getvalue()

assert isinstance(html, str)
assert html == "".join(expected)

def test_partial(self) -> None:
rainbow = "\x1b[1m\x1b[40m\x1b[31mr\x1b[32ma\x1b[33mi\x1b[34mn\x1b[35mb\x1b[36mo\x1b[37mw\x1b[0m\n"

Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ setenv =
deps =
mock
pytest
pytest-cov
sitepackages = False
commands =
pytest
commands = python -m pytest -ra --cov=ansi2html --no-cov-on-fail --cov-append

[testenv:lint]
description = Runs all linting tasks
Expand Down

0 comments on commit 3be927a

Please sign in to comment.