Skip to content

Commit

Permalink
Added simple test case for the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusvniekerk authored and rgbkrk committed Aug 15, 2017
1 parent 694c8df commit c5e6ca0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/cloudpickle_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,22 @@ def foo():
finally:
sys.modules.pop("_fake_module", None)

def test_dynamic_pytest_module(self):
# Test case for pull request https://github.com/cloudpipe/cloudpickle/pull/116
import py

def f():
s = py.builtin.set([1])
return s.pop()

# some setup is required to allow pytest apimodules to be correctly serializable.
from cloudpickle import CloudPickler
from py._apipkg import ApiModule
CloudPickler.dispatch[ApiModule] = CloudPickler.save_module
g = cloudpickle.loads(cloudpickle.dumps(f))

result = g()
self.assertEqual(1, result)

if __name__ == '__main__':
unittest.main()

0 comments on commit c5e6ca0

Please sign in to comment.