Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions tests/cloudpickle_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1816,6 +1816,23 @@ def test___reduce___returns_string(self):
some_singleton, protocol=self.protocol)
assert depickled_singleton is some_singleton

def test_cloudpickle_extract_nested_globals(self):
def function_factory():
def inner_function():
global _TEST_GLOBAL_VARIABLE
return _TEST_GLOBAL_VARIABLE
return inner_function

globals_ = cloudpickle.CloudPickler.extract_code_globals(
function_factory.__code__)
assert globals_ == {'_TEST_GLOBAL_VARIABLE'}

depickled_factory = pickle_depickle(function_factory,
protocol=self.protocol)
inner_func = depickled_factory()
assert inner_func() == _TEST_GLOBAL_VARIABLE


class Protocol2CloudPickleTest(CloudPickleTest):

protocol = 2
Expand Down