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):
|
||||
with pytest.raises(SystemExit):
|
||||
toddlers.plugins.packager_bugzilla_sync.main([])
|
||||
|
||||
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 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={}))
|
||||
def test_main_debug(self, capsys):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue