Skip to content

Commit c5e6ca0

Browse files
mariusvniekerkrgbkrk
authored andcommitted
Added simple test case for the issue
1 parent 694c8df commit c5e6ca0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/cloudpickle_test.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,22 @@ def foo():
680680
finally:
681681
sys.modules.pop("_fake_module", None)
682682

683+
def test_dynamic_pytest_module(self):
684+
# Test case for pull request https://github.com/cloudpipe/cloudpickle/pull/116
685+
import py
686+
687+
def f():
688+
s = py.builtin.set([1])
689+
return s.pop()
690+
691+
# some setup is required to allow pytest apimodules to be correctly serializable.
692+
from cloudpickle import CloudPickler
693+
from py._apipkg import ApiModule
694+
CloudPickler.dispatch[ApiModule] = CloudPickler.save_module
695+
g = cloudpickle.loads(cloudpickle.dumps(f))
696+
697+
result = g()
698+
self.assertEqual(1, result)
683699

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

0 commit comments

Comments
 (0)