mirror of
https://github.com/httpie/cli.git
synced 2025-06-20 09:37:45 +02:00
commit
c42bd0051a
@ -4,7 +4,7 @@ NOTE: the CLI interface may change before reaching v1.0.
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
from textwrap import dedent, wrap
|
from textwrap import dedent, wrap
|
||||||
#noinspection PyCompatibility
|
# noinspection PyCompatibility
|
||||||
from argparse import (RawDescriptionHelpFormatter, FileType,
|
from argparse import (RawDescriptionHelpFormatter, FileType,
|
||||||
OPTIONAL, ZERO_OR_MORE, SUPPRESS)
|
OPTIONAL, ZERO_OR_MORE, SUPPRESS)
|
||||||
|
|
||||||
|
@ -573,7 +573,7 @@ class RequestItemsDict(OrderedDict):
|
|||||||
else:
|
else:
|
||||||
super(RequestItemsDict, self).__init__(*args, **kwargs)
|
super(RequestItemsDict, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
#noinspection PyMethodOverriding
|
# noinspection PyMethodOverriding
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
""" If `key` is assigned more than once, `self[key]` holds a
|
""" If `key` is assigned more than once, `self[key]` holds a
|
||||||
`list` of all the values.
|
`list` of all the values.
|
||||||
|
@ -54,4 +54,3 @@ def humanize_bytes(n, precision=2):
|
|||||||
|
|
||||||
# noinspection PyUnboundLocalVariable
|
# noinspection PyUnboundLocalVariable
|
||||||
return '%.*f %s' % (precision, n / factor, suffix)
|
return '%.*f %s' % (precision, n / factor, suffix)
|
||||||
|
|
||||||
|
6
setup.py
6
setup.py
@ -40,12 +40,12 @@ install_requires = [
|
|||||||
'Pygments>=1.5'
|
'Pygments>=1.5'
|
||||||
]
|
]
|
||||||
|
|
||||||
### Conditional dependencies:
|
# Conditional dependencies:
|
||||||
|
|
||||||
# sdist
|
# sdist
|
||||||
if not 'bdist_wheel' in sys.argv:
|
if 'bdist_wheel' not in sys.argv:
|
||||||
try:
|
try:
|
||||||
#noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
import argparse
|
import argparse
|
||||||
except ImportError:
|
except ImportError:
|
||||||
install_requires.append('argparse>=1.2.1')
|
install_requires.append('argparse>=1.2.1')
|
||||||
|
@ -38,4 +38,3 @@ with open(BIN_FILE_PATH, 'rb') as f:
|
|||||||
BIN_FILE_CONTENT = f.read()
|
BIN_FILE_CONTENT = f.read()
|
||||||
|
|
||||||
UNICODE = FILE_CONTENT
|
UNICODE = FILE_CONTENT
|
||||||
|
|
||||||
|
@ -59,4 +59,3 @@ class TestAuth:
|
|||||||
assert args.auth
|
assert args.auth
|
||||||
assert args.auth.key == 'username'
|
assert args.auth.key == 'username'
|
||||||
assert args.auth.value == ''
|
assert args.auth.value == ''
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ from utils import TESTS_ROOT
|
|||||||
|
|
||||||
def has_docutils():
|
def has_docutils():
|
||||||
try:
|
try:
|
||||||
#noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
import docutils
|
import docutils
|
||||||
return True
|
return True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -64,17 +64,20 @@ class TestSessionFlow(SessionTestBase):
|
|||||||
def test_session_update(self, httpbin):
|
def test_session_update(self, httpbin):
|
||||||
self.start_session(httpbin)
|
self.start_session(httpbin)
|
||||||
# Get a response to a request from the original session.
|
# Get a response to a request from the original session.
|
||||||
r2 = http('--session=test', 'GET', httpbin.url + '/get', env=self.env())
|
r2 = http('--session=test', 'GET', httpbin.url + '/get',
|
||||||
|
env=self.env())
|
||||||
assert HTTP_OK in r2
|
assert HTTP_OK in r2
|
||||||
|
|
||||||
# Make a request modifying the session data.
|
# Make a request modifying the session data.
|
||||||
r3 = http('--follow', '--session=test', '--auth=username:password2',
|
r3 = http('--follow', '--session=test', '--auth=username:password2',
|
||||||
'GET', httpbin.url + '/cookies/set?hello=world2', 'Hello:World2',
|
'GET', httpbin.url + '/cookies/set?hello=world2',
|
||||||
|
'Hello:World2',
|
||||||
env=self.env())
|
env=self.env())
|
||||||
assert HTTP_OK in r3
|
assert HTTP_OK in r3
|
||||||
|
|
||||||
# Get a response to a request from the updated session.
|
# Get a response to a request from the updated session.
|
||||||
r4 = http('--session=test', 'GET', httpbin.url + '/get', env=self.env())
|
r4 = http('--session=test', 'GET', httpbin.url + '/get',
|
||||||
|
env=self.env())
|
||||||
assert HTTP_OK in r4
|
assert HTTP_OK in r4
|
||||||
assert r4.json['headers']['Hello'] == 'World2'
|
assert r4.json['headers']['Hello'] == 'World2'
|
||||||
assert r4.json['headers']['Cookie'] == 'hello=world2'
|
assert r4.json['headers']['Cookie'] == 'hello=world2'
|
||||||
@ -84,7 +87,8 @@ class TestSessionFlow(SessionTestBase):
|
|||||||
def test_session_read_only(self, httpbin):
|
def test_session_read_only(self, httpbin):
|
||||||
self.start_session(httpbin)
|
self.start_session(httpbin)
|
||||||
# Get a response from the original session.
|
# Get a response from the original session.
|
||||||
r2 = http('--session=test', 'GET', httpbin.url + '/get', env=self.env())
|
r2 = http('--session=test', 'GET', httpbin.url + '/get',
|
||||||
|
env=self.env())
|
||||||
assert HTTP_OK in r2
|
assert HTTP_OK in r2
|
||||||
|
|
||||||
# Make a request modifying the session data but
|
# Make a request modifying the session data but
|
||||||
@ -96,7 +100,8 @@ class TestSessionFlow(SessionTestBase):
|
|||||||
assert HTTP_OK in r3
|
assert HTTP_OK in r3
|
||||||
|
|
||||||
# Get a response from the updated session.
|
# Get a response from the updated session.
|
||||||
r4 = http('--session=test', 'GET', httpbin.url + '/get', env=self.env())
|
r4 = http('--session=test', 'GET', httpbin.url + '/get',
|
||||||
|
env=self.env())
|
||||||
assert HTTP_OK in r4
|
assert HTTP_OK in r4
|
||||||
|
|
||||||
# Origin can differ on Travis.
|
# Origin can differ on Travis.
|
||||||
@ -117,8 +122,8 @@ class TestSession(SessionTestBase):
|
|||||||
'If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT',
|
'If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT',
|
||||||
env=self.env())
|
env=self.env())
|
||||||
assert HTTP_OK in r1
|
assert HTTP_OK in r1
|
||||||
|
r2 = http('--session=test', 'GET', httpbin.url + '/get',
|
||||||
r2 = http('--session=test', 'GET', httpbin.url + '/get', env=self.env())
|
env=self.env())
|
||||||
assert HTTP_OK in r2
|
assert HTTP_OK in r2
|
||||||
assert no_content_type(r2.json['headers'])
|
assert no_content_type(r2.json['headers'])
|
||||||
assert 'If-Unmodified-Since' not in r2.json['headers']
|
assert 'If-Unmodified-Since' not in r2.json['headers']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user