MCPcopy Create free account
hub / github.com/cloudpipe/cloudpickle / test_import

Method test_import

tests/cloudpickle_test.py:1153–1177  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1151 assert not subprocess.call([sys.executable, "-c", command])
1152
1153 def test_import(self):
1154 # like test_multiprocess except subpackage modules referenced directly
1155 # (unlike test_submodule)
1156 global etree
1157
1158 def scope():
1159 import xml.etree as foobar
1160
1161 def example():
1162 _ = etree.Comment
1163 _ = foobar.ElementTree
1164
1165 return example
1166
1167 example = scope()
1168 import xml.etree.ElementTree as etree
1169
1170 s = cloudpickle.dumps(example, protocol=self.protocol)
1171
1172 command = (
1173 "import base64; from pickle import loads; loads(base64.b32decode('"
1174 + base64.b32encode(s).decode("ascii")
1175 + "'))()"
1176 )
1177 assert not subprocess.call([sys.executable, "-c", command])
1178
1179 def test_multiprocessing_lock_raises(self):
1180 lock = multiprocessing.Lock()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected