Skip to content

Commit

Permalink
Change test_pickle_globals to not check __globals__ directly
Browse files Browse the repository at this point in the history
Implementation taken from cloudpipe/cloudpickle#202 (comment)
  • Loading branch information
mrocklin committed Sep 14, 2018
1 parent 0910b41 commit a067314
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions dask/tests/test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@
def test_pickle_globals():
""" For the function f(x) defined below, the only globals added in pickling
should be 'np' and '__builtins__'"""
def f(x):
return np.sin(x) + np.cos(x)
def unrelated_function(a):
return np.array([a])

assert set(['np', '__builtins__']) == set(
_loads(_dumps(f)).__globals__.keys())
def my_small_function(a, b):
return a + b

b = _dumps(my_small_function)
assert b'my_small_function' in b
assert b'unrelated_function' not in b
assert b'numpy' not in b


def bad():
Expand Down

0 comments on commit a067314

Please sign in to comment.