Exemplo n.º 1
0
 def test_string(self):
     headers = HTTPHeaders()
     headers.add("Foo", "1")
     headers.add("Foo", "2")
     headers.add("Foo", "3")
     headers2 = HTTPHeaders.parse(str(headers))
     self.assertEquals(headers, headers2)
Exemplo n.º 2
0
 def test_pickle_roundtrip(self):
     headers = HTTPHeaders()
     headers.add('Set-Cookie', 'a=b')
     headers.add('Set-Cookie', 'c=d')
     headers.add('Content-Type', 'text/html')
     pickled = pickle.dumps(headers)
     unpickled = pickle.loads(pickled)
     self.assertEqual(sorted(headers.get_all()), sorted(unpickled.get_all()))
     self.assertEqual(sorted(headers.items()), sorted(unpickled.items()))
Exemplo n.º 3
0
 def test_copy(self):
     all_pairs = [('A', '1'), ('A', '2'), ('B', 'c')]
     h1 = HTTPHeaders()
     for k, v in all_pairs:
         h1.add(k, v)
     h2 = h1.copy()
     h3 = copy.copy(h1)
     h4 = copy.deepcopy(h1)
     for headers in [h1, h2, h3, h4]:
         # All the copies are identical, no matter how they were
         # constructed.
         self.assertEqual(list(sorted(headers.get_all())), all_pairs)
     for headers in [h2, h3, h4]:
         # Neither the dict or its member lists are reused.
         self.assertIsNot(headers, h1)
         self.assertIsNot(headers.get_list('A'), h1.get_list('A'))