aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/yarl/tests/test_pickle.py
blob: a1f29ab68c663ad0a26176fcdc78089207d5d4c9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import pickle

from yarl import URL

# serialize


def test_pickle():
    u1 = URL("test")
    hash(u1)
    v = pickle.dumps(u1)
    u2 = pickle.loads(v)
    assert u1._cache
    assert not u2._cache
    assert hash(u1) == hash(u2)


def test_default_style_state():
    u = URL("test")
    hash(u)
    u.__setstate__((None, {"_val": "test", "_strict": False, "_cache": {"hash": 1}}))
    assert not u._cache
    assert u._val == "test"