forked from extern/httpie-cli
Add main entry point tests
This commit is contained in:
parent
d9b3a16fa6
commit
9bae27354e
@ -1,6 +1,11 @@
|
||||
"""High-level tests."""
|
||||
import io
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
import httpie.__main__
|
||||
from httpie.context import Environment
|
||||
from httpie.status import ExitStatus
|
||||
from httpie.cli.exceptions import ParseError
|
||||
from utils import MockEnvironment, http, HTTP_OK
|
||||
@ -9,6 +14,23 @@ from fixtures import FILE_PATH, FILE_CONTENT
|
||||
import httpie
|
||||
|
||||
|
||||
def test_main_entry_point():
|
||||
# Patch stdin to bypass pytest capture
|
||||
with mock.patch.object(Environment, 'stdin', io.StringIO()):
|
||||
with pytest.raises(SystemExit) as e:
|
||||
httpie.__main__.main()
|
||||
assert e.value.code == ExitStatus.ERROR
|
||||
|
||||
|
||||
@mock.patch('httpie.core.main')
|
||||
def test_main_entry_point_keyboard_interrupt(main):
|
||||
main.side_effect = KeyboardInterrupt()
|
||||
with mock.patch.object(Environment, 'stdin', io.StringIO()):
|
||||
with pytest.raises(SystemExit) as e:
|
||||
httpie.__main__.main()
|
||||
assert e.value.code == ExitStatus.ERROR_CTRL_C
|
||||
|
||||
|
||||
def test_debug():
|
||||
r = http('--debug')
|
||||
assert r.exit_status == ExitStatus.SUCCESS
|
||||
|
Loading…
Reference in New Issue
Block a user