Tests: Cope with different invocation methods
Depending on how the tests are run (`pytest`, `python -m pytest`, ...), the program name can be e.g. `pytest` or `pytest.py`. Relax the relevant tests a bit, this way we don't have to update them every time we change something related to CLI arguments either. Signed-off-by: Nils Philippsen <nils@redhat.com>
This commit is contained in:
parent
3207b68d46
commit
c5de49c6d8
2 changed files with 14 additions and 8 deletions
|
@ -118,12 +118,15 @@ class TestPackagerBugzillaSyncToddler:
|
||||||
def test_main_no_args(self, capsys):
|
def test_main_no_args(self, capsys):
|
||||||
with pytest.raises(SystemExit):
|
with pytest.raises(SystemExit):
|
||||||
toddlers.plugins.packager_bugzilla_sync.main([])
|
toddlers.plugins.packager_bugzilla_sync.main([])
|
||||||
|
|
||||||
out, err = capsys.readouterr()
|
out, err = capsys.readouterr()
|
||||||
exp = """usage: pytest [-h] [--dry-run] [-q | --debug] conf [username]
|
|
||||||
pytest: error: the following arguments are required: conf
|
|
||||||
"""
|
|
||||||
assert out == ""
|
assert out == ""
|
||||||
assert err == exp
|
# Expecting something along these lines, but don't make the test too tight:
|
||||||
|
#
|
||||||
|
# usage: pytest [-h] [--dry-run] [-q | --debug] conf [username]
|
||||||
|
# pytest: error: the following arguments are required: conf
|
||||||
|
assert err.startswith("usage:")
|
||||||
|
assert "error: the following arguments are required:" in err
|
||||||
|
|
||||||
@patch("toml.load", new=Mock(return_value={}))
|
@patch("toml.load", new=Mock(return_value={}))
|
||||||
def test_main_debug(self, capsys):
|
def test_main_debug(self, capsys):
|
||||||
|
|
|
@ -12,12 +12,15 @@ class TestPlaytime:
|
||||||
def test_playtime_no_args(self, capsys):
|
def test_playtime_no_args(self, capsys):
|
||||||
with pytest.raises(SystemExit):
|
with pytest.raises(SystemExit):
|
||||||
toddlers.playtime.main([])
|
toddlers.playtime.main([])
|
||||||
|
|
||||||
out, err = capsys.readouterr()
|
out, err = capsys.readouterr()
|
||||||
exp = """usage: pytest [-h] [--conf CONF] [--debug] name
|
|
||||||
pytest: error: the following arguments are required: name
|
|
||||||
"""
|
|
||||||
assert out == ""
|
assert out == ""
|
||||||
assert err == exp
|
# Expecting something along these lines, but don't make the test too tight:
|
||||||
|
#
|
||||||
|
# usage: pytest [-h] [--conf CONF] [--debug] name
|
||||||
|
# pytest: error: the following arguments are required: name
|
||||||
|
assert err.startswith("usage:")
|
||||||
|
assert "error: the following arguments are required:" in err
|
||||||
|
|
||||||
def test_playtime_arg(self, capsys):
|
def test_playtime_arg(self, capsys):
|
||||||
with fedora_messaging.testing.mock_sends(
|
with fedora_messaging.testing.mock_sends(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue