From d4385f6fc84854d78f838f4eb3a93dd3985242c5 Mon Sep 17 00:00:00 2001 From: Robert Estelle Date: Tue, 30 Jul 2013 23:01:56 -0700 Subject: [PATCH] Add Request.copy() test case. --- test_requests.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/test_requests.py b/test_requests.py index 27d5e67..ee08834 100755 --- a/test_requests.py +++ b/test_requests.py @@ -458,6 +458,37 @@ class RequestsTestCase(unittest.TestCase): self.assertTrue(hasattr(resp, 'hook_working')) + def test_request_copy(self): + a = requests.Request('POST', httpbin('post'), + headers={'oh': 'gee'}, + files={'some': 'thing'}, + data={'baz':'qux'}, + params={'foo': 'bar'}, + auth=object(), + cookies={'Some-Cookie':'Some Value'}, + hooks={'response': lambda r: r }) + b = a.copy() + + self.assertNotEqual(a, b) + self.assertEqual(a.method, b.method) + self.assertEqual(a.url, b.url) + self.assertEqual(a.headers, b.headers) + self.assertEqual(a.files, b.files) + self.assertEqual(a.data, b.data) + self.assertEqual(a.params, b.params) + self.assertEqual(a.auth, b.auth) + self.assertEqual(a.cookies, b.cookies) + self.assertEqual(a.hooks, b.hooks) + + a.headers['Foo'] = 'Bar' + self.assertNotEqual(a.headers, b.headers) + + a.data['x'] = 'y' + self.assertNotEqual(a.data, b.data) + + a.params['_'] = '?' + self.assertNotEqual(a.params, b.params) + def test_links(self): r = requests.Response() r.headers = { -- 2.7.4