Allow copying of PreparedRequests without headers/cookies

This commit is contained in:
David Gouldin
2014-05-30 10:11:53 -07:00
parent 69996114d9
commit 32f600b083
2 changed files with 30 additions and 2 deletions
+28
View File
@@ -1369,6 +1369,34 @@ def test_data_argument_accepts_tuples(list_of_tuples):
)
assert p.body == urlencode(data)
def assert_copy(p, p_copy):
for attr in ('method', 'url', 'headers', '_cookies', 'body', 'hooks'):
assert getattr(p, attr) == getattr(p_copy, attr)
def test_prepared_request_empty_copy():
p = PreparedRequest()
assert_copy(p, p.copy())
def test_prepared_request_no_cookies_copy():
p = PreparedRequest()
p.prepare(
method='GET',
url='http://www.example.com',
data='foo=bar',
hooks=default_hooks()
)
assert_copy(p, p.copy())
def test_prepared_request_complete_copy():
p = PreparedRequest()
p.prepare(
method='GET',
url='http://www.example.com',
data='foo=bar',
hooks=default_hooks(),
cookies={'foo': 'bar'}
)
assert_copy(p, p.copy())
if __name__ == '__main__':
unittest.main()