| 1 |
import re |
| 2 |
import pytest |
| 3 |
|
| 4 |
# "gen" is the abbreviated name for "getentityname.py" |
| 5 |
import gen |
| 6 |
|
| 7 |
|
| 8 |
def test_help(capsys): |
| 9 |
# given |
| 10 |
# n/a |
| 11 |
|
| 12 |
# when |
| 13 |
with pytest.raises(SystemExit): |
| 14 |
gen.main(["prog", "--help"]) |
| 15 |
|
| 16 |
# then |
| 17 |
assert capsys.readouterr() |
| 18 |
|
| 19 |
|
| 20 |
def test_invalid(capsys): |
| 21 |
# given |
| 22 |
# n/a |
| 23 |
|
| 24 |
# when |
| 25 |
with pytest.raises(SystemExit): |
| 26 |
gen.main(["prog", "--asdf"]) |
| 27 |
|
| 28 |
# then |
| 29 |
assert capsys.readouterr() |
| 30 |
|
| 31 |
|
| 32 |
def test_version(capsys): |
| 33 |
# given |
| 34 |
# n/a |
| 35 |
|
| 36 |
# when |
| 37 |
with pytest.raises(SystemExit): |
| 38 |
gen.main(["prog", "--version"]) |
| 39 |
captured = capsys.readouterr() |
| 40 |
|
| 41 |
# then |
| 42 |
assert captured.out.rstrip() == gen.__version__ |