Added tests for --debug and --help.

This commit is contained in:
Jakub Roztocil 2014-04-24 18:32:15 +02:00
parent 887f70f595
commit bdea7be456
3 changed files with 19 additions and 3 deletions

View File

@ -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,

View File

@ -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)

View File

@ -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