コード例 #1
0
    def test_join_header_words(self):
        from ClientCookie._HeadersUtil import join_header_words

        assert join_header_words([[("foo", None), ("bar", "baz"),
                                   (None, "value")]]) == "foo; bar=baz; value"

        assert join_header_words([[]]) == ""
コード例 #2
0
ファイル: test_headers.py プロジェクト: B-Rich/paytoopass
    def test_join_header_words(self):
        from ClientCookie._HeadersUtil import join_header_words

        assert join_header_words([[
            ("foo", None), ("bar", "baz"), (None, "value")
            ]]) == "foo; bar=baz; value"

        assert join_header_words([[]]) == ""
コード例 #3
0
ファイル: test_headers.py プロジェクト: raidenawkward/django
    def test_roundtrip(self):
        from ClientCookie._HeadersUtil import split_header_words, join_header_words

        tests = [
            ("foo", "foo"),
            ("foo=bar", "foo=bar"),
            ("   foo   ", "foo"),
            ("foo=", 'foo=""'),
            ("foo=bar bar=baz", "foo=bar; bar=baz"),
            ("foo=bar;bar=baz", "foo=bar; bar=baz"),
            ("foo bar baz", "foo; bar; baz"),
            (r'foo="\"" bar="\\"', r'foo="\""; bar="\\"'),
            ("foo,,,bar", "foo, bar"),
            ("foo=bar,bar=baz", "foo=bar, bar=baz"),
            ("text/html; charset=iso-8859-1", 'text/html; charset="iso-8859-1"'),
            ('foo="bar"; port="80,81"; discard, bar=baz', 'foo=bar; port="80,81"; discard, bar=baz'),
            (r'Basic realm="\"foo\\\\bar\""', r'Basic; realm="\"foo\\\\bar\""'),
        ]

        for arg, expect in tests:
            input = split_header_words([arg])
            res = join_header_words(input)
            assert (
                res == expect
            ), """
When parsing: '%s'
Expected:     '%s'
Got:          '%s'
Input was:    '%s'""" % (
                arg,
                expect,
                res,
                input,
            )
コード例 #4
0
    def test_roundtrip(self):
        from ClientCookie._HeadersUtil import split_header_words, join_header_words

        tests = [("foo", "foo"), ("foo=bar", "foo=bar"), ("   foo   ", "foo"),
                 ("foo=", 'foo=""'), ("foo=bar bar=baz", "foo=bar; bar=baz"),
                 ("foo=bar;bar=baz", "foo=bar; bar=baz"),
                 ('foo bar baz', "foo; bar; baz"),
                 (r'foo="\"" bar="\\"', r'foo="\""; bar="\\"'),
                 ('foo,,,bar', 'foo, bar'),
                 ('foo=bar,bar=baz', 'foo=bar, bar=baz'),
                 ('text/html; charset=iso-8859-1',
                  'text/html; charset="iso-8859-1"'),
                 ('foo="bar"; port="80,81"; discard, bar=baz',
                  'foo=bar; port="80,81"; discard, bar=baz'),
                 (r'Basic realm="\"foo\\\\bar\""',
                  r'Basic; realm="\"foo\\\\bar\""')]

        for arg, expect in tests:
            input = split_header_words([arg])
            res = join_header_words(input)
            assert res == expect, """
When parsing: '%s'
Expected:     '%s'
Got:          '%s'
Input was:    '%s'""" % (arg, expect, res, input)