def test_parent(): x = [4,5,6,7] listiter = iter(x) obj = parent(listiter, list) assert obj is x if IS_PYPY: assert parent(obj, int) is None else: assert parent(obj, int) is x[-1] # python oddly? finds last int assert at(id(at)) is at
def test_parent(): x = [4, 5, 6, 7] listiter = iter(x) obj = parent(listiter, list) assert obj is x if IS_PYPY: assert parent(obj, int) is None else: assert parent(obj, int) is x[-1] # python oddly? finds last int assert at(id(at)) is at
assert badobjects(f) is f assert badtypes(f) == type(f) assert type(errors(f)) is PicklingError if IS_PYPY else TypeError d = badtypes(f, 1) assert isinstance(d, dict) assert list(badobjects(f, 1).keys()) == list(d.keys()) assert list(errors(f, 1).keys()) == list(d.keys()) s = set([(err.__class__.__name__, err.args[0]) for err in list(errors(f, 1).values())]) a = dict(s) assert len(s) is len(a) # TypeError (and possibly PicklingError) assert len(a) is 2 if 'PicklingError' in a.keys() else 1 x = [4, 5, 6, 7] listiter = iter(x) obj = parent(listiter, list) assert obj is x if IS_PYPY: assert parent(obj, int) is None else: assert parent(obj, int) is x[-1] # python oddly? finds last int assert at(id(at)) is at def f(): a def g(): b def h(): c
#!/usr/bin/env python # # Author: Mike McKerns (mmckerns @caltech and @uqfoundation) # Copyright (c) 2008-2015 California Institute of Technology. # License: 3-clause BSD. The full license text is available at: # - http://trac.mystic.cacr.caltech.edu/project/pathos/browser/dill/LICENSE from dill.detect import baditems, badobjects, badtypes, errors, parent, at import inspect f = inspect.currentframe() assert baditems(f) == [f] #assert baditems(globals()) == [f] #XXX assert badobjects(f) is f assert badtypes(f) == type(f) assert isinstance(errors(f), TypeError) d = badtypes(f, 1) assert isinstance(d, dict) assert list(badobjects(f, 1).keys()) == list(d.keys()) assert list(errors(f, 1).keys()) == list(d.keys()) assert len(set([err.args[0] for err in list(errors(f, 1).values())])) is 1 x = [4, 5, 6, 7] listiter = iter(x) obj = parent(listiter, list) assert obj is x assert parent(obj, int) is x[-1] assert at(id(at)) is at
#assert baditems(globals()) == [f] #XXX assert badobjects(f) is f assert badtypes(f) == type(f) assert isinstance(errors(f), TypeError) d = badtypes(f, 1) assert isinstance(d, dict) assert list(badobjects(f, 1).keys()) == list(d.keys()) assert list(errors(f, 1).keys()) == list(d.keys()) s = set([(err.__class__.__name__,err.args[0]) for err in list(errors(f, 1).values())]) a = dict(s) assert len(s) is len(a) # TypeError (and possibly PicklingError) assert len(a) is 2 if 'PicklingError' in a.keys() else 1 x = [4,5,6,7] listiter = iter(x) obj = parent(listiter, list) assert obj is x assert parent(obj, int) is x[-1] assert at(id(at)) is at def f(): a def g(): b def h(): c a, b, c = 1, 2, 3 assert globalvars(f) == dict(a=1, b=2, c=3) def squared(x):
#assert baditems(globals()) == [f] #XXX assert badobjects(f) is f assert badtypes(f) == type(f) assert type(errors(f)) is PicklingError if IS_PYPY else TypeError d = badtypes(f, 1) assert isinstance(d, dict) assert list(badobjects(f, 1).keys()) == list(d.keys()) assert list(errors(f, 1).keys()) == list(d.keys()) s = set([(err.__class__.__name__,err.args[0]) for err in list(errors(f, 1).values())]) a = dict(s) assert len(s) is len(a) # TypeError (and possibly PicklingError) assert len(a) is 2 if 'PicklingError' in a.keys() else 1 x = [4,5,6,7] listiter = iter(x) obj = parent(listiter, list) assert obj is x if IS_PYPY: assert parent(obj, int) is None else: assert parent(obj, int) is x[-1] # python oddly? finds last int assert at(id(at)) is at def f(): a def g(): b def h(): c a, b, c = 1, 2, 3 assert globalvars(f) == dict(a=1, b=2, c=3)
assert badobjects(f) is f assert badtypes(f) == type(f) assert type(errors(f)) is PicklingError if IS_PYPY else TypeError d = badtypes(f, 1) assert isinstance(d, dict) assert list(badobjects(f, 1).keys()) == list(d.keys()) assert list(errors(f, 1).keys()) == list(d.keys()) s = set([(err.__class__.__name__, err.args[0]) for err in list(errors(f, 1).values())]) a = dict(s) assert len(s) is len(a) # TypeError (and possibly PicklingError) assert len(a) is 2 if 'PicklingError' in a.keys() else 1 x = [4, 5, 6, 7] listiter = iter(x) obj = parent(listiter, list) assert obj is x assert parent(obj, int) is x[-1] #FIXME: pypy # print (parent(obj, int), x[-1]) # (returns None) -- parent does not find int assert at(id(at)) is at def f(): a def g(): b def h():
#assert baditems(globals()) == [f] #XXX assert badobjects(f) is f assert badtypes(f) == type(f) assert type(errors(f)) is PicklingError if IS_PYPY else TypeError d = badtypes(f, 1) assert isinstance(d, dict) assert list(badobjects(f, 1).keys()) == list(d.keys()) assert list(errors(f, 1).keys()) == list(d.keys()) s = set([(err.__class__.__name__,err.args[0]) for err in list(errors(f, 1).values())]) a = dict(s) assert len(s) is len(a) # TypeError (and possibly PicklingError) assert len(a) is 2 if 'PicklingError' in a.keys() else 1 x = [4,5,6,7] listiter = iter(x) obj = parent(listiter, list) assert obj is x assert parent(obj, int) is x[-1] #FIXME: pypy # print (parent(obj, int), x[-1]) # (returns None) -- parent does not find int assert at(id(at)) is at def f(): a def g(): b def h(): c a, b, c = 1, 2, 3 assert globalvars(f) == dict(a=1, b=2, c=3)