Skip to content

Commit

Permalink
add test for producing just headers as command
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
  • Loading branch information
ziegenberg committed Oct 30, 2021
1 parent f3c2b78 commit 02c627d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
16 changes: 16 additions & 0 deletions tests/test_ansi2html.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,22 @@ def test_partial_as_command(
assert isinstance(expected, str)
self.assertEqual(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
11 changes: 1 addition & 10 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ minversion = 3.9.0
envlist =
lint
py{36,37,38,39}
report
packaging

isolated_build = True
Expand All @@ -17,7 +16,7 @@ deps =
pytest
pytest-cov
sitepackages = False
commands = python -m pytest -ra --cov=ansi2html --no-cov-on-fail --cov-append --cov-report=
commands = python -m pytest -ra --cov=ansi2html --no-cov-on-fail --cov-append

[testenv:lint]
description = Runs all linting tasks
Expand Down Expand Up @@ -57,14 +56,6 @@ whitelist_externals =
rm
sh

[testenv:report]
description = Generate test coverage report
skip_install = true
deps = coverage
commands =
coverage html
coverage report --fail-under=80

[testenv:docs]
description = Generate Sphinx docs under build/docs
extras = docs
Expand Down

0 comments on commit 02c627d

Please sign in to comment.