提交 c236db89 authored 作者: Michael Osthege's avatar Michael Osthege 提交者: Thomas Wiecki

Add test for config pickling

上级 7b86ac5a
"""Test config options.""" """Test config options."""
import configparser as stdlib_configparser import configparser as stdlib_configparser
import io
import pickle
import pytest import pytest
...@@ -256,6 +258,22 @@ def test_mode_apply(): ...@@ -256,6 +258,22 @@ def test_mode_apply():
) )
def test_config_pickling():
# check that the real thing can be pickled
root = configdefaults.config
pickle.dump(root, io.BytesIO())
# and validate that the test would catch typical problems
root = _create_test_config()
root.add(
"test__lambda_kills_pickling",
"Lambda functions cause pickling problems.",
configparser.IntParam(5, lambda i: i > 0),
)
with pytest.raises(AttributeError, match="Can't pickle local object"):
pickle.dump(root, io.BytesIO())
class TestConfigHelperFunctions: class TestConfigHelperFunctions:
@pytest.mark.parametrize( @pytest.mark.parametrize(
"release,platform,answer", "release,platform,answer",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论