提交 edea0b85 authored 作者: Michael Osthege's avatar Michael Osthege 提交者: Brandon T. Willard

Improve tests.test_config pickling test

上级 8628ecf9
......@@ -261,7 +261,18 @@ def test_mode_apply():
def test_config_pickling():
# check that the real thing can be pickled
root = configdefaults.config
pickle.dump(root, io.BytesIO())
buffer = io.BytesIO()
pickle.dump(root, buffer)
# and also unpickled...
buffer.seek(0)
restored = pickle.load(buffer)
# ...without a change in the config values
for name in root._config_var_dict.keys():
v_original = getattr(root, name)
v_restored = getattr(restored, name)
assert (
v_restored == v_original
), f"{name} did not survive pickling ({v_restored} != {v_original})"
# and validate that the test would catch typical problems
root = _create_test_config()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论