mirror of
https://github.com/httpie/cli.git
synced 2025-06-25 12:01:41 +02:00
Add main entry point tests
This commit is contained in:
parent
d9b3a16fa6
commit
9bae27354e
@ -1,6 +1,11 @@
|
|||||||
"""High-level tests."""
|
"""High-level tests."""
|
||||||
|
import io
|
||||||
|
from unittest import mock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
import httpie.__main__
|
||||||
|
from httpie.context import Environment
|
||||||
from httpie.status import ExitStatus
|
from httpie.status import ExitStatus
|
||||||
from httpie.cli.exceptions import ParseError
|
from httpie.cli.exceptions import ParseError
|
||||||
from utils import MockEnvironment, http, HTTP_OK
|
from utils import MockEnvironment, http, HTTP_OK
|
||||||
@ -9,6 +14,23 @@ from fixtures import FILE_PATH, FILE_CONTENT
|
|||||||
import httpie
|
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():
|
def test_debug():
|
||||||
r = http('--debug')
|
r = http('--debug')
|
||||||
assert r.exit_status == ExitStatus.SUCCESS
|
assert r.exit_status == ExitStatus.SUCCESS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user