Skip to content

Commit

Permalink
help silence some test noise
Browse files Browse the repository at this point in the history
  • Loading branch information
mmckerns committed Jun 26, 2022
1 parent 2cbc2a9 commit ecf60d0
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
5 changes: 4 additions & 1 deletion dill/_dill.py
Original file line number Diff line number Diff line change
Expand Up @@ -2373,7 +2373,10 @@ def check(obj, *args, **kwds):
# unpickle = "dill.loads(%s, ignore=%s)"%(repr(_obj), repr(ignore))
# cmd = [python, "-c", "import dill; print(%s)"%unpickle]
# msg = "SUCCESS" if not subprocess.call(cmd) else "LOAD FAILED"
msg = "%s -c import dill; print(dill.loads(%s))" % (python, repr(_obj))
if verbose is None:
msg = "%s -c import dill; dill.loads(%s)" % (python, repr(_obj))
else:
msg = "%s -c import dill; print(dill.loads(%s))" % (python, repr(_obj))
msg = "SUCCESS" if not subprocess.call(msg.split(None,2)) else "LOAD FAILED"
if verbose:
print(msg)
Expand Down
6 changes: 3 additions & 3 deletions dill/_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ class _Struct(ctypes.Structure):
# built-in functions (CH 2)
# Iterators:
a['ListIteratorType'] = iter(_list) # empty vs non-empty
a['SetIteratorType'] = iter(_set) #XXX: empty vs non-empty
a['SetIteratorType'] = iter(_set) #XXX: empty vs non-empty #FIXME: list_iterator
a['TupleIteratorType']= iter(_tuple) # empty vs non-empty
a['XRangeIteratorType'] = iter(_xrange) # empty vs non-empty
a["BytesIteratorType"] = iter(b'')
Expand All @@ -429,9 +429,9 @@ class _Struct(ctypes.Structure):
d["OdictKeysType"] = X.keys()
d["OdictValuesType"] = X.values()
d["OdictItemsType"] = X.items()
a["OdictIteratorType"] = iter(X.keys())
a["OdictIteratorType"] = iter(X.keys()) #FIXME: list_iterator
del X
if PY3:
if PY3: #FIXME: list_iterator
a['DictionaryItemIteratorType'] = iter(type.__dict__.items())
a['DictionaryKeyIteratorType'] = iter(type.__dict__.keys())
a['DictionaryValueIteratorType'] = iter(type.__dict__.values())
Expand Down
20 changes: 10 additions & 10 deletions tests/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,24 @@ def raise_check(func, **kwds):
f = lambda x:x**2


def test_simple():
raise_check(f)
def test_simple(verbose=None):
raise_check(f, verbose=verbose)


def test_recurse():
raise_check(f, recurse=True)
def test_recurse(verbose=None):
raise_check(f, recurse=True, verbose=verbose)


def test_byref():
raise_check(f, byref=True)
def test_byref(verbose=None):
raise_check(f, byref=True, verbose=verbose)


def test_protocol():
raise_check(f, protocol=True)
def test_protocol(verbose=None):
raise_check(f, protocol=True, verbose=verbose)


def test_python():
raise_check(f, python=None)
def test_python(verbose=None):
raise_check(f, python=None, verbose=verbose)


#TODO: test incompatible versions
Expand Down
2 changes: 2 additions & 0 deletions tests/test_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ def test_objects():
pickles(member, exact=False)

if __name__ == '__main__':
import warnings
warnings.simplefilter('ignore')
test_objects()
7 changes: 7 additions & 0 deletions tests/test_selected.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ def _method(self):
from dill import load_types
load_types(pickleable=True,unpickleable=False)
_newclass = objects['ClassObjectType']
# some clean-up #FIXME: should happen internal to dill
objects['TemporaryFileType'].close()
objects['TextWrapperType'].close()
objects['BufferedRandomType'].close()
objects['BufferedReaderType'].close()
objects['BufferedWriterType'].close()
objects['FileType'].close()
del objects

# getset_descriptor for new-style classes (fails on '_method', if not __main__)
Expand Down

0 comments on commit ecf60d0

Please sign in to comment.