Skip to content

Commit

Permalink
Merge cf2abe4 into b4ed5ce
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdonnnj committed Oct 7, 2020
2 parents b4ed5ce + cf2abe4 commit 292404e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
--editable .[test]
--requirement requirements.txt
-e .[test]
5 changes: 5 additions & 0 deletions src/example/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""Code to run if this package is used as a Python module."""

from .example import main

main()
2 changes: 0 additions & 2 deletions src/example/example.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

"""example is an example Python library and tool.
Divide one integer by another and log the result. Also log some information
Expand Down
12 changes: 12 additions & 0 deletions tests/test_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ def test_stdout_version(capsys):
), "standard output by '--version' should agree with module.__version__"


def test___main__(capsys):
"""Verify that the __main__.py file loads correctly."""
with pytest.raises(SystemExit):
with patch.object(sys, "argv", ["bogus", "--version"]):
# cisagov Libraries
import example.__main__ # noqa: F401
captured = capsys.readouterr()
assert (
captured.out == f"{PROJECT_VERSION}\n"
), "standard output by '--version' should agree with module.__version__"


@pytest.mark.skipif(
RELEASE_TAG in [None, ""], reason="this is not a release (RELEASE_TAG not set)"
)
Expand Down

0 comments on commit 292404e

Please sign in to comment.