MCPcopy Create free account
hub / github.com/pybind/pybind11 / test_roundtrip

Function test_roundtrip

tests/test_pickling.py:52–62  ·  view source on GitHub ↗
(cls_name)

Source from the content-addressed store, hash-verified

50
51@pytest.mark.parametrize("cls_name", ["Pickleable", "PickleableNew"])
52def test_roundtrip(cls_name):
53 cls = getattr(m, cls_name)
54 p = cls("test_value")
55 p.setExtra1(15)
56 p.setExtra2(48)
57
58 data = pickle.dumps(p, 2) # Must use pickle protocol >= 2
59 p2 = pickle.loads(data)
60 assert p2.value() == p.value()
61 assert p2.extra1() == p.extra1()
62 assert p2.extra2() == p.extra2()
63
64
65@pytest.mark.xfail("env.PYPY")

Callers

nothing calls this directly

Calls 6

getattrFunction · 0.85
setExtra1Method · 0.80
setExtra2Method · 0.80
extra1Method · 0.80
extra2Method · 0.80
valueMethod · 0.45

Tested by

no test coverage detected