MCPcopy
hub / github.com/pallets/werkzeug / test_basic_interface

Method test_basic_interface

tests/test_datastructures.py:650–678  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

648 storage_class = ds.Headers
649
650 def test_basic_interface(self):
651 headers = self.storage_class()
652 headers.add("Content-Type", "text/plain")
653 headers.add("X-Foo", "bar")
654 assert "x-Foo" in headers
655 assert "Content-type" in headers
656
657 with pytest.raises(ValueError):
658 headers.add("X-Example", "foo\r\n bar")
659
660 headers["Content-Type"] = "foo/bar"
661 assert headers["Content-Type"] == "foo/bar"
662 assert len(headers.getlist("Content-Type")) == 1
663
664 # list conversion
665 assert headers.to_wsgi_list() == [("Content-Type", "foo/bar"), ("X-Foo", "bar")]
666 assert str(headers) == "Content-Type: foo/bar\r\nX-Foo: bar\r\n\r\n"
667 assert str(self.storage_class()) == "\r\n"
668
669 # extended add
670 headers.add("Content-Disposition", "attachment", filename="foo")
671 assert headers["Content-Disposition"] == "attachment; filename=foo"
672
673 headers.add("x", "y", z='"')
674 assert headers["x"] == r'y; z="\""'
675
676 # string conversion
677 headers.add("a", 1)
678 assert headers["a"] == "1"
679
680 def test_defaults_and_conversion(self):
681 # defaults

Callers

nothing calls this directly

Calls 3

to_wsgi_listMethod · 0.80
addMethod · 0.45
getlistMethod · 0.45

Tested by

no test coverage detected