File size: 436 Bytes
065fee7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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"