Skip to content

Commit

Permalink
TST: Verify the same pickle string is produced with global variables …
Browse files Browse the repository at this point in the history
…(fails)
  • Loading branch information
effigies committed Apr 21, 2021
1 parent 8d63a2e commit b9d2bdc
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/cloudpickle_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
from cloudpickle.cloudpickle import _extract_class_dict, _whichmodule
from cloudpickle.cloudpickle import _lookup_module_and_qualname

from .testutils import subprocess_pickle_string
from .testutils import subprocess_pickle_echo
from .testutils import assert_run_python_script
from .testutils import subprocess_worker
Expand All @@ -57,6 +58,7 @@


_TEST_GLOBAL_VARIABLE = "default_value"
_TEST_GLOBAL_VARIABLE2 = "another_value"


class RaiserOnPickle(object):
Expand Down Expand Up @@ -2321,6 +2323,19 @@ def __type__(self):
o = MyClass()
pickle_depickle(o, protocol=self.protocol)

def test_sorted_globals(self):
vals = set()

def func_with_globals():
return _TEST_GLOBAL_VARIABLE + _TEST_GLOBAL_VARIABLE2

for i in range(5):
vals.add(
subprocess_pickle_string(func_with_globals,
protocol=self.protocol,
add_env={"PYTHONHASHSEED": str(i)}))
assert len(vals) == 1


class Protocol2CloudPickleTest(CloudPickleTest):

Expand Down

0 comments on commit b9d2bdc

Please sign in to comment.