Skip to content

Commit

Permalink
TST clearly separate test-cases
Browse files Browse the repository at this point in the history
  • Loading branch information
pierreglaser committed May 17, 2019
1 parent 4f041b4 commit 5aea555
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions tests/cloudpickle_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,26 +628,17 @@ def test_builtin_function(self):

@pytest.mark.skipif(platform.python_implementation() == 'PyPy' and
sys.version_info[:2] == (3, 5),
reason="bug of pypy3.5 in builtin constructors")
def test_builtin_method(self):
# Note that builtin_function_or_method are special-cased by cloudpickle
# only in python2.
reason="bug of pypy3.5 in builtin-type constructors")
def test_builtin_type_constructor(self):
# Due to a bug in pypy3.5, cloudpickling builtin-type constructors
# fails. This test makes sure that cloudpickling builtin-type
# constructors works for all other python versions/implementation.

# pickle_depickle some builtin methods of the __builtin__ module
for t in list, tuple, set, frozenset, dict, object:
cloned_new = pickle_depickle(t.__new__, protocol=self.protocol)
assert isinstance(cloned_new(t), t)

# pickle_depickle a method of a "regular" module
fi = itertools.chain.from_iterable
fi_depickled = pickle_depickle(fi, protocol=self.protocol)

# `fi is fi_depickled` would return False, but so will
# `itertools.chain.from_iterable is itertools.chain.from_iterable`.
# Instead of testing physical equality, check that `fi_depickled`
# behaves as expected.
self.assertEqual(list(fi_depickled([[1, 2], [3, 4]])), [1, 2, 3, 4])

# The next 4 tests cover all cases into which builtin python methods can
# appear.
# There are 4 kinds of method: 'classic' methods, classmethods,
Expand Down

0 comments on commit 5aea555

Please sign in to comment.