| 344 | ) |
| 345 | |
| 346 | def test_copy(self): |
| 347 | all_pairs = [("A", "1"), ("A", "2"), ("B", "c")] |
| 348 | h1 = HTTPHeaders() |
| 349 | for k, v in all_pairs: |
| 350 | h1.add(k, v) |
| 351 | h2 = h1.copy() |
| 352 | h3 = copy.copy(h1) |
| 353 | h4 = copy.deepcopy(h1) |
| 354 | for headers in [h1, h2, h3, h4]: |
| 355 | # All the copies are identical, no matter how they were |
| 356 | # constructed. |
| 357 | self.assertEqual(list(sorted(headers.get_all())), all_pairs) |
| 358 | for headers in [h2, h3, h4]: |
| 359 | # Neither the dict or its member lists are reused. |
| 360 | self.assertIsNot(headers, h1) |
| 361 | self.assertIsNot(headers.get_list("A"), h1.get_list("A")) |
| 362 | |
| 363 | def test_pickle_roundtrip(self): |
| 364 | headers = HTTPHeaders() |