Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_class_instances():
assert dill.pickles(o)
assert dill.pickles(oc)
assert dill.pickles(n)
assert dill.pickles(nc)
assert dill.pickles(m)
def test_monkey_patch_pickle(f):
f_temp = _wrap_task_call(f)
assert dill.pickles(f_temp), "{} is not pickling correctly!".format(f)
# Pickle everything
s1 = dill.dumps(f_temp)
s2 = dill.loads(s1)
dill.dumps(s2)
def test_class_instances():
assert dill.pickles(o)
assert dill.pickles(oc)
assert dill.pickles(n)
assert dill.pickles(nc)
assert dill.pickles(m)
def test_decorated():
assert dill.pickles(f2)
return np.asarray(self), self.color
a1 = TestArray(np.zeros(100), color='green')
assert dill.pickles(a1)
assert a1.__dict__ == dill.copy(a1).__dict__
a2 = a1[0:9]
assert dill.pickles(a2)
assert a2.__dict__ == dill.copy(a2).__dict__
class TestArray2(np.ndarray):
color = 'blue'
a3 = TestArray2([1,2,3,4,5])
a3.color = 'green'
assert dill.pickles(a3)
assert a3.__dict__ == dill.copy(a3).__dict__
except ImportError: pass
def test_class_instances():
assert dill.pickles(o)
assert dill.pickles(oc)
assert dill.pickles(n)
assert dill.pickles(nc)
assert dill.pickles(m)
def test_class_descriptors():
d = _d.__dict__
for i in d.values():
ok = dill.pickles(i)
if verbose: print ("%s: %s, %s" % (ok, type(i), i))
assert ok
if verbose: print ("")
od = _newclass.__dict__
for i in od.values():
ok = dill.pickles(i)
if verbose: print ("%s: %s, %s" % (ok, type(i), i))
assert ok
if verbose: print ("")
def badobjects(obj, depth=0, exact=False, safe=False):
"""get objects that fail to pickle"""
from dill import pickles
if not depth:
if pickles(obj,exact,safe): return None
return obj
return dict(((attr, badobjects(getattr(obj,attr),depth-1,exact,safe)) \
for attr in dir(obj) if not pickles(getattr(obj,attr),exact,safe)))
def badtypes(obj, depth=0, exact=False, safe=False):
"""get types for objects that fail to pickle"""
from dill import pickles
if not depth:
if pickles(obj,exact,safe): return None
return type(obj)
return dict(((attr, badtypes(getattr(obj,attr),depth-1,exact,safe)) \
for attr in dir(obj) if not pickles(getattr(obj,attr),exact,safe)))