Skip to content

Commit

Permalink
#773 allow cmdline to be called bot with and without args, make args …
Browse files Browse the repository at this point in the history
…use sys.args if not specified (#777)

(cherry picked from commit 83f9a62)
  • Loading branch information
gaborbernat authored and obestwalter committed Mar 23, 2018
1 parent 6f0b7dc commit 3ab6296
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion tests/test_z_cmdline.py
Expand Up @@ -902,12 +902,17 @@ def test_tox_quickstart_script():
assert result == 0


def test_tox_cmdline(monkeypatch):
def test_tox_cmdline_no_args(monkeypatch):
monkeypatch.setattr(sys, 'argv', ['caller_script', '--help'])
with pytest.raises(SystemExit):
tox.cmdline()


def test_tox_cmdline_args(monkeypatch):
with pytest.raises(SystemExit):
tox.cmdline(['caller_script', '--help'])


@pytest.mark.parametrize('exit_code', [0, 6])
def test_exit_code(initproj, cmd, exit_code, mocker):
""" Check for correct InvocationError, with exit code,
Expand Down
6 changes: 4 additions & 2 deletions tox/session.py
Expand Up @@ -34,8 +34,10 @@ def prepare(args):
return config


def run_main():
main(sys.argv[1:])
def run_main(args=None):
if args is None:
args = sys.argv[1:]
main(args)


def main(args):
Expand Down

0 comments on commit 3ab6296

Please sign in to comment.