Ejemplo n.º 1
0
def test_pairs_roundtrips():
    pairs = [
        [
            "",
            []
        ],
        [
            "one=uno",
            [["one", "uno"]]
        ],
        [
            "one",
            [["one", None]]
        ],
        [
            "one=uno; two=due",
            [["one", "uno"], ["two", "due"]]
        ],
        [
            'one="uno"; two="\due"',
            [["one", "uno"], ["two", "due"]]
        ],
        [
            'one="un\\"o"',
            [["one", 'un"o']]
        ],
        [
            'one="uno,due"',
            [["one", 'uno,due']]
        ],
        [
            "one=uno; two; three=tre",
            [["one", "uno"], ["two", None], ["three", "tre"]]
        ],
        [
            "_lvs2=zHai1+Hq+Tc2vmc2r4GAbdOI5Jopg3EwsdUT9g=; "
            "_rcc2=53VdltWl+Ov6ordflA==;",
            [
                ["_lvs2", "zHai1+Hq+Tc2vmc2r4GAbdOI5Jopg3EwsdUT9g="],
                ["_rcc2", "53VdltWl+Ov6ordflA=="]
            ]
        ]
    ]
    for s, lst in pairs:
        ret, off = cookies._read_pairs(s)
        assert ret == lst
        s2 = cookies._format_pairs(lst)
        ret, off = cookies._read_pairs(s2)
        assert ret == lst
Ejemplo n.º 2
0
def test_read_pairs():
    vals = [
        [
            "one",
            [["one", None]]
        ],
        [
            "one=two",
            [["one", "two"]]
        ],
        [
            "one=",
            [["one", ""]]
        ],
        [
            'one="two"',
            [["one", "two"]]
        ],
        [
            'one="two"; three=four',
            [["one", "two"], ["three", "four"]]
        ],
        [
            'one="two"; three=four; five',
            [["one", "two"], ["three", "four"], ["five", None]]
        ],
        [
            'one="\\"two"; three=four',
            [["one", '"two'], ["three", "four"]]
        ],
    ]
    for s, lst in vals:
        ret, off = cookies._read_pairs(s)
        assert ret == lst
Ejemplo n.º 3
0
def test_pairs_roundtrips():
    pairs = [["", []], ["one=uno", [["one", "uno"]]], ["one", [["one", None]]],
             ["one=uno; two=due", [["one", "uno"], ["two", "due"]]],
             ['one="uno"; two="\due"', [["one", "uno"], ["two", "due"]]],
             ['one="un\\"o"', [["one", 'un"o']]],
             ['one="uno,due"', [["one", 'uno,due']]],
             [
                 "one=uno; two; three=tre",
                 [["one", "uno"], ["two", None], ["three", "tre"]]
             ],
             [
                 "_lvs2=zHai1+Hq+Tc2vmc2r4GAbdOI5Jopg3EwsdUT9g=; "
                 "_rcc2=53VdltWl+Ov6ordflA==;",
                 [["_lvs2", "zHai1+Hq+Tc2vmc2r4GAbdOI5Jopg3EwsdUT9g="],
                  ["_rcc2", "53VdltWl+Ov6ordflA=="]]
             ]]
    for s, lst in pairs:
        ret, off = cookies._read_pairs(s)
        assert ret == lst
        s2 = cookies._format_pairs(lst)
        ret, off = cookies._read_pairs(s2)
        assert ret == lst
Ejemplo n.º 4
0
def test_read_pairs():
    vals = [
        ["one", [["one", None]]],
        ["one=two", [["one", "two"]]],
        ["one=", [["one", ""]]],
        ['one="two"', [["one", "two"]]],
        ['one="two"; three=four', [["one", "two"], ["three", "four"]]],
        [
            'one="two"; three=four; five',
            [["one", "two"], ["three", "four"], ["five", None]]
        ],
        ['one="\\"two"; three=four', [["one", '"two'], ["three", "four"]]],
    ]
    for s, lst in vals:
        ret, off = cookies._read_pairs(s)
        assert ret == lst