diff --git a/httpie/core.py b/httpie/core.py index fbcd7a3a..fc762b60 100644 --- a/httpie/core.py +++ b/httpie/core.py @@ -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, diff --git a/tests/__init__.py b/tests/__init__.py index 9782b755..8c9e503d 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -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) diff --git a/tests/test_httpie.py b/tests/test_httpie.py index b4a9e142..28c712e8 100644 --- a/tests/test_httpie.py +++ b/tests/test_httpie.py @@ -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