mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 00:06:44 -04:00
stdpy: Add PicklingError to pickle module
This commit is contained in:
parent
d3ebeee058
commit
65c1ef968c
@ -33,6 +33,8 @@ else:
|
||||
# with the local pickle.py.
|
||||
pickle = __import__('pickle')
|
||||
|
||||
PicklingError = pickle.PicklingError
|
||||
|
||||
if sys.version_info >= (3, 0):
|
||||
BasePickler = pickle._Pickler
|
||||
BaseUnpickler = pickle._Unpickler
|
||||
|
@ -1,4 +1,5 @@
|
||||
from direct.stdpy.pickle import dumps, loads
|
||||
from direct.stdpy.pickle import dumps, loads, PicklingError
|
||||
import pytest
|
||||
|
||||
|
||||
def test_reduce_persist():
|
||||
@ -9,3 +10,12 @@ def test_reduce_persist():
|
||||
|
||||
parent2, child2 = loads(dumps([parent, child]))
|
||||
assert tuple(parent2.children) == (child2,)
|
||||
|
||||
|
||||
def test_pickle_error():
|
||||
class ErroneousPickleable(object):
|
||||
def __reduce__(self):
|
||||
return 12345
|
||||
|
||||
with pytest.raises(PicklingError):
|
||||
dumps(ErroneousPickleable())
|
||||
|
Loading…
x
Reference in New Issue
Block a user