You've already forked httpie-cli
mirror of
https://github.com/httpie/cli.git
synced 2025-06-17 00:17:45 +02:00
Cleanup
XX
This commit is contained in:
@ -8,7 +8,6 @@ from tests.fixtures import BIN_FILE_PATH, BIN_FILE_CONTENT, BIN_FILE_PATH_ARG
|
||||
|
||||
|
||||
class BinaryRequestDataTest(TestCase):
|
||||
|
||||
def test_binary_stdin(self):
|
||||
with open(BIN_FILE_PATH, 'rb') as stdin:
|
||||
env = TestEnvironment(
|
||||
@ -16,47 +15,23 @@ class BinaryRequestDataTest(TestCase):
|
||||
stdin_isatty=False,
|
||||
stdout_isatty=False
|
||||
)
|
||||
r = http(
|
||||
'--print=B',
|
||||
'POST',
|
||||
httpbin('/post'),
|
||||
env=env,
|
||||
)
|
||||
r = http('--print=B', 'POST', httpbin('/post'), env=env)
|
||||
assert r == BIN_FILE_CONTENT
|
||||
|
||||
def test_binary_file_path(self):
|
||||
env = TestEnvironment(
|
||||
stdin_isatty=True,
|
||||
stdout_isatty=False
|
||||
)
|
||||
r = http(
|
||||
'--print=B',
|
||||
'POST',
|
||||
httpbin('/post'),
|
||||
'@' + BIN_FILE_PATH_ARG,
|
||||
env=env,
|
||||
)
|
||||
|
||||
env = TestEnvironment(stdin_isatty=True, stdout_isatty=False)
|
||||
r = http('--print=B', 'POST', httpbin('/post'),
|
||||
'@' + BIN_FILE_PATH_ARG, env=env, )
|
||||
assert r == BIN_FILE_CONTENT
|
||||
|
||||
def test_binary_file_form(self):
|
||||
env = TestEnvironment(
|
||||
stdin_isatty=True,
|
||||
stdout_isatty=False
|
||||
)
|
||||
r = http(
|
||||
'--print=B',
|
||||
'--form',
|
||||
'POST',
|
||||
httpbin('/post'),
|
||||
'test@' + BIN_FILE_PATH_ARG,
|
||||
env=env,
|
||||
)
|
||||
env = TestEnvironment(stdin_isatty=True, stdout_isatty=False)
|
||||
r = http('--print=B', '--form', 'POST', httpbin('/post'),
|
||||
'test@' + BIN_FILE_PATH_ARG, env=env)
|
||||
assert bytes(BIN_FILE_CONTENT) in bytes(r)
|
||||
|
||||
|
||||
class BinaryResponseDataTest(TestCase):
|
||||
|
||||
url = 'http://www.google.com/favicon.ico'
|
||||
|
||||
@property
|
||||
@ -66,27 +41,16 @@ class BinaryResponseDataTest(TestCase):
|
||||
return self._bindata
|
||||
|
||||
def test_binary_suppresses_when_terminal(self):
|
||||
r = http(
|
||||
'GET',
|
||||
self.url
|
||||
)
|
||||
r = http('GET', self.url)
|
||||
assert BINARY_SUPPRESSED_NOTICE.decode() in r
|
||||
|
||||
def test_binary_suppresses_when_not_terminal_but_pretty(self):
|
||||
r = http(
|
||||
'--pretty=all',
|
||||
'GET',
|
||||
self.url,
|
||||
env=TestEnvironment(stdin_isatty=True,
|
||||
stdout_isatty=False)
|
||||
)
|
||||
env = TestEnvironment(stdin_isatty=True, stdout_isatty=False)
|
||||
r = http('--pretty=all', 'GET', self.url,
|
||||
env=env)
|
||||
assert BINARY_SUPPRESSED_NOTICE.decode() in r
|
||||
|
||||
def test_binary_included_and_correct_when_suitable(self):
|
||||
r = http(
|
||||
'GET',
|
||||
self.url,
|
||||
env=TestEnvironment(stdin_isatty=True,
|
||||
stdout_isatty=False)
|
||||
)
|
||||
env = TestEnvironment(stdin_isatty=True, stdout_isatty=False)
|
||||
r = http('GET', self.url, env=env)
|
||||
assert r == self.bindata
|
||||
|
Reference in New Issue
Block a user