From 147a305da8c7c5e1fa44d073f97c865f4e81bfd7 Mon Sep 17 00:00:00 2001 From: Gert Van Gool Date: Mon, 13 Jul 2015 14:21:12 +0200 Subject: [PATCH 1/3] Adds extra tests for CaseInsensitiveDict - Test for NotImplemented in __eq__ - Adds test for copy() - Adds test for __repr__() --- test_requests.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test_requests.py b/test_requests.py index 4ffd6847..168a2d93 100755 --- a/test_requests.py +++ b/test_requests.py @@ -1224,6 +1224,7 @@ class TestCaseInsensitiveDict(unittest.TestCase): del othercid['spam'] assert cid != othercid assert cid == {'spam': 'blueval', 'eggs': 'redval'} + assert cid.__eq__(object()) == NotImplemented def test_setdefault(self): cid = CaseInsensitiveDict({'Spam': 'blueval'}) @@ -1261,6 +1262,20 @@ class TestCaseInsensitiveDict(unittest.TestCase): assert frozenset(cid.keys()) == keyset assert frozenset(cid) == keyset + def test_copy(self): + cid = CaseInsensitiveDict({ + 'Accept': 'application/json', + 'user-Agent': 'requests', + }) + assert cid == cid.copy() + + def test_repr(self): + cid = CaseInsensitiveDict({ + 'Accept': 'application/json', + 'user-Agent': 'requests', + }) + assert repr(cid) == "{'Accept': 'application/json', 'user-Agent': 'requests'}" + class UtilsTestCase(unittest.TestCase): From 47e71d1774745543b743bdf570d9d8e7151355e6 Mon Sep 17 00:00:00 2001 From: Gert Van Gool Date: Mon, 13 Jul 2015 15:07:38 +0200 Subject: [PATCH 2/3] Don't test the NotImplemented, just make sure it's False --- test_requests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_requests.py b/test_requests.py index 168a2d93..aac4d8d0 100755 --- a/test_requests.py +++ b/test_requests.py @@ -1224,7 +1224,7 @@ class TestCaseInsensitiveDict(unittest.TestCase): del othercid['spam'] assert cid != othercid assert cid == {'spam': 'blueval', 'eggs': 'redval'} - assert cid.__eq__(object()) == NotImplemented + assert cid != object() def test_setdefault(self): cid = CaseInsensitiveDict({'Spam': 'blueval'}) From 3b325f1bc5df476c4c4e93c5a742d81e2c5bd950 Mon Sep 17 00:00:00 2001 From: Gert Van Gool Date: Tue, 14 Jul 2015 08:10:13 +0200 Subject: [PATCH 3/3] assert that the copy() is not the original --- test_requests.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test_requests.py b/test_requests.py index aac4d8d0..5f4f472a 100755 --- a/test_requests.py +++ b/test_requests.py @@ -1267,7 +1267,10 @@ class TestCaseInsensitiveDict(unittest.TestCase): 'Accept': 'application/json', 'user-Agent': 'requests', }) - assert cid == cid.copy() + cid_copy = cid.copy() + assert cid == cid_copy + cid['changed'] = True + assert cid != cid_copy def test_repr(self): cid = CaseInsensitiveDict({