23 lines
663 B
Python
23 lines
663 B
Python
from unittest import mock
|
|
import pytest
|
|
from magicli import magicli
|
|
|
|
|
|
def test_help_message(capsys):
|
|
inputs = [
|
|
'appname --help',
|
|
'appname command --help',
|
|
'appname command --name=Name --amount=3 --help',
|
|
]
|
|
help_message='Usage:\n appname command_with_arguments --positional --optional\n'
|
|
for i in inputs:
|
|
args = i.split()
|
|
with mock.patch('sys.argv', args):
|
|
with pytest.raises(SystemExit):
|
|
magicli(exclude=['test_help_message'])
|
|
out, err = capsys.readouterr()
|
|
assert out.startswith(help_message)
|
|
|
|
|
|
def command_with_arguments(positional, optional=True):
|
|
pass |