Ejemplo n.º 1
0
 def test_replace_simple(self):
     headers = Headers(Host="example.com", Accept="text/plain")
     replacements = headers.replace("Host: ", "X-Host: ")
     assert replacements == 1
     assert headers["X-Host"] == "example.com"
     assert "Host" not in headers
     assert headers["Accept"] == "text/plain"
Ejemplo n.º 2
0
 def test_replace_simple(self):
     headers = Headers(Host="example.com", Accept="text/plain")
     replacements = headers.replace("Host: ", "X-Host: ")
     assert replacements == 1
     assert headers["X-Host"] == "example.com"
     assert "Host" not in headers
     assert headers["Accept"] == "text/plain"
Ejemplo n.º 3
0
 def test_replace_with_count(self):
     headers = Headers(Host="foobarfoo.com", Accept="foo/bar")
     replacements = headers.replace("foo", "bar", count=1)
     assert replacements == 1
Ejemplo n.º 4
0
 def test_replace_remove_spacer(self):
     headers = Headers(Host="example.com")
     replacements = headers.replace(r"Host: ", "X-Host ")
     assert replacements == 0
     assert headers["Host"] == "example.com"
Ejemplo n.º 5
0
 def test_replace_with_count(self):
     headers = Headers(Host="foobarfoo.com", Accept="foo/bar")
     replacements = headers.replace("foo", "bar", count=1)
     assert replacements == 1
Ejemplo n.º 6
0
 def test_replace_remove_spacer(self):
     headers = Headers(Host="example.com")
     replacements = headers.replace(r"Host: ", "X-Host ")
     assert replacements == 0
     assert headers["Host"] == "example.com"