added:tests/test_structures.py+79 added
1+# coding: utf-82+import pytest3+4+from requests.structures import CaseInsensitiveDict, LookupDict5+6+7+class TestCaseInsensitiveDict:8+9+ @pytest.fixture(autouse=True)10+ def setup(self):11+ """12+ CaseInsensitiveDict instance with "Accept" header.13+ """14+ self.case_insensitive_dict = CaseInsensitiveDict()15+ self.case_insensitive_dict['Accept'] = 'application/json'16+17+ def test_list(self):18+ assert list(self.case_insensitive_dict) == ['Accept']19+20+ possible_keys = pytest.mark.parametrize('key', ('accept', 'ACCEPT', 'aCcEpT', 'Accept'))21+22+ @possible_keys23+ def test_getitem(self, key):24+ assert self.case_insensitive_dict[key] == 'application/json'25+26+ @possible_keys27+ def test_delitem(self, key):28+ del self.case_insensitive_dict[key]29+ assert key not in self.case_insensitive_dict30+31+ def test_lower_items(self):32+ assert list(self.case_insensitive_dict.lower_items()) == [('accept', 'application/json')]33+34+ def test_repr(self):35+ assert repr(self.case_insensitive_dict) == "{'Accept': 'application/json'}"36+37+ def test_copy(self):38+ copy = self.case_insensitive_dict.copy()39+ assert copy is not self.case_insensitive_dict40+ assert copy == self.case_insensitive_dict41+42+ @pytest.mark.parametrize(43+ 'other, result', (44+ ({'AccePT': 'application/json'}, True),45+ ({}, False),46+ (None, False)47+ )48+ )49+ def test_instance_equality(self, other, result):50+ assert (self.case_insensitive_dict == other) is result51+52+53+class TestLookupDict:54+55+ @pytest.fixture(autouse=True)56+ def setup(self):57+ """58+ LookupDict instance with "bad_gateway" attribute.59+ """60+ self.lookup_dict = LookupDict('test')61+ self.lookup_dict.bad_gateway = 50262+63+ def test_repr(self):64+ assert repr(self.lookup_dict) == "<lookup 'test'>"65+66+ get_item_parameters = pytest.mark.parametrize(67+ 'key, value', (68+ ('bad_gateway', 502),69+ ('not_a_key', None)70+ )71+ )72+73+ @get_item_parameters74+ def test_getitem(self, key, value):75+ assert self.lookup_dict[key] == value76+77+ @get_item_parameters78+ def test_get(self, key, value):79+ assert self.lookup_dict.get(key) == value