Add dynamic attribute support

This commit is contained in:
Dean Moldovan
2016-10-11 01:12:48 +02:00
parent 26df852392
commit 6fccf69360
7 changed files with 182 additions and 2 deletions

View File

@@ -3,10 +3,10 @@ try:
except ImportError:
import pickle
from pybind11_tests import Pickleable
def test_roundtrip():
from pybind11_tests import Pickleable
p = Pickleable("test_value")
p.setExtra1(15)
p.setExtra2(48)
@@ -16,3 +16,17 @@ def test_roundtrip():
assert p2.value() == p.value()
assert p2.extra1() == p.extra1()
assert p2.extra2() == p.extra2()
def test_roundtrip_with_dict():
from pybind11_tests import PickleableWithDict
p = PickleableWithDict("test_value")
p.extra = 15
p.dynamic = "Attribute"
data = pickle.dumps(p, pickle.HIGHEST_PROTOCOL)
p2 = pickle.loads(data)
assert p2.value == p.value
assert p2.extra == p.extra
assert p2.dynamic == p.dynamic