示例#1
0
def test_bad_things():
    f = inspect.currentframe()
    assert baditems(f) == [f]
    #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)
    n = 1 if IS_PYPY else 2
    assert len(a) is n if 'PicklingError' in a.keys() else n-1
示例#2
0
def test_bad_things():
    f = inspect.currentframe()
    assert baditems(f) == [f]
    #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)
    n = 1 if IS_PYPY else 2
    assert len(a) is n if 'PicklingError' in a.keys() else n-1
示例#3
0
文件: test_detect.py 项目: kernc/dill
#!/usr/bin/env python
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2008-2016 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, globalvars
from dill import settings
from dill.dill import IS_PYPY
from pickle import PicklingError

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 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]
示例#4
0
#!/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, globalvars
from dill import settings

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())
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
示例#5
0
#!/usr/bin/env python
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2008-2014 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

import inspect

f = inspect.currentframe()
assert baditems(f) == [f]
assert baditems(globals()) == [f]
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]