test_cloudpickle_wrapper.py 729 B

12345678910111213141516171819202122232425262728
  1. """
  2. Test that our implementation of wrap_non_picklable_objects mimics
  3. properly the loky implementation.
  4. """
  5. from .._cloudpickle_wrapper import (
  6. _my_wrap_non_picklable_objects,
  7. wrap_non_picklable_objects,
  8. )
  9. def a_function(x):
  10. return x
  11. class AClass(object):
  12. def __call__(self, x):
  13. return x
  14. def test_wrap_non_picklable_objects():
  15. # Mostly a smoke test: test that we can use callable in the same way
  16. # with both our implementation of wrap_non_picklable_objects and the
  17. # upstream one
  18. for obj in (a_function, AClass()):
  19. wrapped_obj = wrap_non_picklable_objects(obj)
  20. my_wrapped_obj = _my_wrap_non_picklable_objects(obj)
  21. assert wrapped_obj(1) == my_wrapped_obj(1)