23 lines
706 B
Python
23 lines
706 B
Python
from unittest import mock
|
|
import pytest
|
|
from magicli import magicli
|
|
|
|
|
|
def test_command_with_invalid_arguments(capsys):
|
|
inputs = [
|
|
'appname command_with_invalid_arguments --name=Name',
|
|
'appname command_with_invalid_arguments',
|
|
'command_with_invalid_arguments magicli 2 invalid',
|
|
]
|
|
error_message = '\x1b[91mError:\x1b[0m '
|
|
for i in inputs:
|
|
args = i.split()
|
|
with mock.patch('sys.argv', args):
|
|
with pytest.raises(TypeError):
|
|
magicli(exclude=['test_command_with_invalid_arguments'])
|
|
out, err = capsys.readouterr()
|
|
assert out.startswith(error_message)
|
|
|
|
|
|
def command_with_invalid_arguments(name, amount):
|
|
pass |