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

Assure ansi2html can be called as script or module #120

Merged
merged 1 commit into from
Oct 14, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ansi2html/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from ansi2html.converter import main

if __name__ == "__main__":
main()
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ setup_requires =
setuptools_scm >= 1.15.0
setuptools_scm_git_archive >= 1.0

[options.entry_points]
console_scripts =
ansi2html = ansi2html.__main__:main

[options.packages.find]
where = .

Expand Down
9 changes: 9 additions & 0 deletions tests/test_ansi2html.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import unittest
from io import StringIO
from os.path import abspath, dirname, join
from subprocess import run

from mock import patch

Expand Down Expand Up @@ -385,6 +386,14 @@ def test_latex_linkify(self):
latex = Ansi2HTMLConverter(latex=True, inline=True, linkify=True).convert(ansi)
assert target in latex

def test_command_script(self):
result = run(["ansi2html", "--version"], check=True)
assert result.returncode == 0

def test_command_module(self):
result = run(["python3", "-m", "ansi2html", "--version"], check=True)
assert result.returncode == 0


if __name__ == "__main__":
unittest.main()