Skip to content

Commit

Permalink
More tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jkbrzt committed Apr 24, 2014
1 parent ce2169f commit e5d758e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
7 changes: 3 additions & 4 deletions httpie/input.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Parsing and processing of CLI input (args, auth credentials, files, stdin).
"""
import argparse
import os
import sys
import re
Expand Down Expand Up @@ -163,7 +162,8 @@ def _print_message(self, message, file=None):
sys.stderr: self.env.stderr,
None: self.env.stderr
}.get(file, file)

if not hasattr(file, 'buffer'):
message = message.encode('utf8')
super(Parser, self)._print_message(message, file)

def _setup_standard_streams(self):
Expand Down Expand Up @@ -637,6 +637,5 @@ def readable_file_arg(filename):
try:
open(filename, 'rb')
except IOError as ex:
raise argparse.ArgumentTypeError(
'%s: %s' % (filename, ex.args[1]))
raise ArgumentTypeError('%s: %s' % (filename, ex.args[1]))
return filename
10 changes: 0 additions & 10 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,6 @@ def http(*args, **kwargs):
>>> r.json is None
True
$ http --version:
>>> r = http('--version')
>>> r.exit_status
1
>>> r.stderr.strip() == httpie.__version__
True
>>> r == ''
True
"""
env = kwargs.get('env')
if not env:
Expand Down
5 changes: 5 additions & 0 deletions tests/test_httpie.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ def test_help(self):
assert r.exit_status == httpie.ExitStatus.ERROR
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):
r = http('GET', httpbin('/get'))
assert HTTP_OK in r
Expand Down

0 comments on commit e5d758e

Please sign in to comment.