MCPcopy Create free account
hub / github.com/cdgriffith/Box / test_pickle

Method test_pickle

test/test_box.py:891–907  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

889 my_box["g"]
890
891 def test_pickle(self):
892 if platform.python_implementation() == "PyPy":
893 pytest.skip("Pickling does not work correctly on PyPy")
894 pic_file = os.path.join(tmp_dir, "test.p")
895 pic2_file = os.path.join(tmp_dir, "test.p2")
896 bb = Box(movie_data, conversion_box=False)
897 pickle.dump(bb, open(pic_file, "wb"))
898 loaded = pickle.load(open(pic_file, "rb"))
899 assert bb == loaded
900 assert loaded._box_config["conversion_box"] is False
901
902 ll = [[Box({"a": "b"})], [[{"c": "g"}]]]
903 bx = BoxList(ll)
904 pickle.dump(bx, open(pic2_file, "wb"))
905 loaded2 = pickle.load(open(pic2_file, "rb"))
906 assert bx == loaded2
907 loaded2.box_options = bx.box_options
908
909 def test_pickle_preserves_subclass_on_nested_access(self):
910 if platform.python_implementation() == "PyPy":

Callers

nothing calls this directly

Calls 2

BoxClass · 0.90
BoxListClass · 0.90

Tested by

no test coverage detected