class CaseInsensitiveCasePreservingDictTests(SimpleTestCase): def setUp(self): self.dict = CaseInsensitiveCasePreservingDict() self.dict["Accept"] = "application/text+xml" self.dict["accEPT"] = "application/json" def test_preserves_first_key(self): self.assertEqual(list(self.dict.keys()), ["Accept"]) def test_copy(self): copy = self.dict.copy() self.assertIsNot(copy, self.dict) self.assertEqual(copy, self.dict) # Here's why the superclass CaseInsensitiveDict.copy is insufficient: self.assertIsInstance(copy, CaseInsensitiveCasePreservingDict) def test_get_item(self): self.assertEqual(self.dict["accept"], "application/json") self.assertEqual(self.dict["Accept"], "application/json") self.assertEqual(self.dict["accEPT"], "application/json")
def setUp(self): self.dict = CaseInsensitiveCasePreservingDict() self.dict["Accept"] = "application/text+xml" self.dict["accEPT"] = "application/json"