mirror of
https://github.com/httpie/cli.git
synced 2024-11-21 23:33:12 +01:00
Added tests for --debug and --help.
This commit is contained in:
parent
887f70f595
commit
bdea7be456
@ -43,7 +43,7 @@ def get_exit_status(http_status, follow=False):
|
||||
|
||||
|
||||
def print_debug_info(env):
|
||||
sys.stderr.writelines([
|
||||
env.stderr.writelines([
|
||||
'HTTPie %s\n' % httpie_version,
|
||||
'HTTPie data: %s\n' % env.config.directory,
|
||||
'Requests %s\n' % requests_version,
|
||||
|
@ -132,10 +132,14 @@ def http(*args, **kwargs):
|
||||
|
||||
stdout = env.stdout
|
||||
stderr = env.stderr
|
||||
try:
|
||||
args = list(args)
|
||||
|
||||
if '--debug' not in args and '--traceback' not in args:
|
||||
args = ['--traceback'] + args
|
||||
print(args)
|
||||
try:
|
||||
try:
|
||||
exit_status = main(args=['--traceback'] + list(args), **kwargs)
|
||||
exit_status = main(args=args, **kwargs)
|
||||
if '--download' in args:
|
||||
# Let the progress reporter thread finish.
|
||||
time.sleep(.5)
|
||||
|
@ -3,10 +3,22 @@ from unittest import TestCase
|
||||
|
||||
from tests import TestEnvironment, http, httpbin, HTTP_OK
|
||||
from tests.fixtures import FILE_PATH, FILE_CONTENT
|
||||
import httpie
|
||||
|
||||
|
||||
class HTTPieTest(TestCase):
|
||||
|
||||
def test_debug(self):
|
||||
r = http('--debug')
|
||||
assert r.exit_status == httpie.ExitStatus.OK
|
||||
assert 'HTTPie %s' % httpie.__version__ in r.stderr
|
||||
assert 'HTTPie data:' in r.stderr
|
||||
|
||||
def test_help(self):
|
||||
r = http('--help')
|
||||
assert r.exit_status == httpie.ExitStatus.ERROR
|
||||
assert 'https://github.com/jkbr/httpie/issues' in r
|
||||
|
||||
def test_GET(self):
|
||||
r = http('GET', httpbin('/get'))
|
||||
assert HTTP_OK in r
|
||||
|
Loading…
Reference in New Issue
Block a user