def test_diff_attributes(): assert hasattr(module, "a") and module.a == 1234 assert module.double_add(1, 2, 3) == 2 * module.fx
def test_attributes(): #assert hasattr(module, "a") and module.a == 1234 #FIXME: -m dill.tests assert module.double_add(1, 2, 3) == 2 * module.fx
cached = (module.__cached__ if hasattr(module, "__cached__") else module.__file__.split(".", 1)[0] + ".pyc") module.a = 1234 pik_mod = dill.dumps(module) module.a = 0 # remove module del sys.modules[module.__name__] del module module = dill.loads(pik_mod) assert hasattr(module, "a") and module.a == 1234 assert module.double_add(1, 2, 3) == 2 * module.fx # Restart, and test use_diff reload(module) try: dill.use_diff() module.a = 1234 pik_mod = dill.dumps(module) module.a = 0 # remove module