-
Notifications
You must be signed in to change notification settings - Fork 98
Description
add below code in the end of tests.test_hook.test_load
test method:
# load with sub_module name and it can be pickled
list_item = ab_2.container.ListItem()
assert list_item == pickle.loads(pickle.dumps(list_item))
fail log is:
> FAILED [100%]
> tests/test_hook.py:31 (test_load)
> def test_load():
> ab_1 = thriftpy2.load("addressbook.thrift")
> ab_2 = thriftpy2.load("addressbook.thrift",
> module_name="addressbook_thrift")
>
> assert ab_1.__name__ == "addressbook"
> assert ab_2.__name__ == "addressbook_thrift"
>
> # load without module_name can't do pickle
> with pytest.raises(pickle.PicklingError):
> pickle.dumps(ab_1.Person(name='Bob'))
>
> # load with module_name set and it can be pickled
> person = ab_2.Person(name='Bob')
> assert person == pickle.loads(pickle.dumps(person))
>
> # load with sub_module name and it can be pickled
> list_item = ab_2.container.ListItem()
> \> assert list_item == pickle.loads(pickle.dumps(list_item))
> E _pickle.PicklingError: Can't pickle <class 'container.ListItem'>: attribute lookup ListItem on container failed
>
> test_hook.py:50: PicklingError
Metadata
Metadata
Assignees
Labels
No labels