More tests.

This commit is contained in:
Jakub Roztocil 2014-04-24 19:32:39 +02:00
parent ce2169f4fe
commit e5d758e4ce
3 changed files with 8 additions and 14 deletions

View File

@ -1,7 +1,6 @@
"""Parsing and processing of CLI input (args, auth credentials, files, stdin). """Parsing and processing of CLI input (args, auth credentials, files, stdin).
""" """
import argparse
import os import os
import sys import sys
import re import re
@ -163,7 +162,8 @@ class Parser(ArgumentParser):
sys.stderr: self.env.stderr, sys.stderr: self.env.stderr,
None: self.env.stderr None: self.env.stderr
}.get(file, file) }.get(file, file)
if not hasattr(file, 'buffer'):
message = message.encode('utf8')
super(Parser, self)._print_message(message, file) super(Parser, self)._print_message(message, file)
def _setup_standard_streams(self): def _setup_standard_streams(self):
@ -637,6 +637,5 @@ def readable_file_arg(filename):
try: try:
open(filename, 'rb') open(filename, 'rb')
except IOError as ex: except IOError as ex:
raise argparse.ArgumentTypeError( raise ArgumentTypeError('%s: %s' % (filename, ex.args[1]))
'%s: %s' % (filename, ex.args[1]))
return filename return filename

View File

@ -107,16 +107,6 @@ def http(*args, **kwargs):
>>> r.json is None >>> r.json is None
True True
$ http --version:
>>> r = http('--version')
>>> r.exit_status
1
>>> r.stderr.strip() == httpie.__version__
True
>>> r == ''
True
""" """
env = kwargs.get('env') env = kwargs.get('env')
if not env: if not env:

View File

@ -19,6 +19,11 @@ class HTTPieTest(TestCase):
assert r.exit_status == httpie.ExitStatus.ERROR assert r.exit_status == httpie.ExitStatus.ERROR
assert 'https://github.com/jkbr/httpie/issues' in r assert 'https://github.com/jkbr/httpie/issues' in r
def test_version(self):
r = http('--version')
assert r.exit_status == httpie.ExitStatus.ERROR
assert httpie.__version__ == r.stderr.strip()
def test_GET(self): def test_GET(self):
r = http('GET', httpbin('/get')) r = http('GET', httpbin('/get'))
assert HTTP_OK in r assert HTTP_OK in r