Esempio n. 1
0
    def test_add(self):
        hd = HTTPHeaderDict()
        hd.add('sound', 'quiet')
        hd.add('SOUND', 'LOUD')
        assert hd.getlist('Sound') == ['quiet', 'LOUD']

        # Enforce type-checking in the add method.
        pytest.raises(ValueError, hd.add, 'Sound', 5)
Esempio n. 2
0
    def test_repr(self):
        hd = HTTPHeaderDict()
        assert repr(hd) == '{}'
        hd.add('type', 'xml')
        assert repr(hd) == "{'type': 'xml'}"
        hd.add('type', 'html')
        assert repr(hd) == "{'type': ('xml', 'html')}"

        # We can't guarantee order once we have more than one key.
        hd.add('Accept', 'text/html')
        assert repr(hd) in [
            "{'type': ('xml', 'html'), 'Accept': 'text/html'}",
            "{'Accept': 'text/html', 'type': ('xml', 'html')}",
        ]
        assert str(hd) == repr(hd)