mirror of
https://github.com/httpie/cli.git
synced 2024-11-22 07:43:20 +01:00
More tests.
This commit is contained in:
parent
ce2169f4fe
commit
e5d758e4ce
@ -1,7 +1,6 @@
|
||||
"""Parsing and processing of CLI input (args, auth credentials, files, stdin).
|
||||
|
||||
"""
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
@ -163,7 +162,8 @@ class Parser(ArgumentParser):
|
||||
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):
|
||||
@ -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
|
||||
|
@ -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:
|
||||
|
@ -19,6 +19,11 @@ class HTTPieTest(TestCase):
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user