本文整理汇总了Python中pypackage.config.Config类的典型用法代码示例。如果您正苦于以下问题:Python Config类的具体用法?Python Config怎么用?Python Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Config类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_perform_guesswork
def test_perform_guesswork(capfd, reset_sys_argv, move_home_pypackage):
"""Ensure the user can deselect guesses when using interactive."""
conf = Config()
conf.name = "previously existing"
sys.argv = ["py-build", "-i"]
guesses = OrderedDict([
("name", "some name"),
("py_modules", "some_thing"),
("scripts", ["bin/something"]),
("package_data", ["thing/data/file_1"]),
])
with mock.patch.object(guessing, "_guess_at_things", return_value=guesses):
with mock.patch.object(guessing, "INPUT",
side_effect=iter(["1", "-3", "2", ""])):
guessing.perform_guesswork(conf, get_options())
assert conf.name == "previously existing"
assert not hasattr(conf, "py_modules")
assert conf.package_data == {"previously existing": ["thing/data/file_1"]}
assert conf.scripts == ["bin/something"]
out, err = capfd.readouterr()
assert "name will not be guessed" in out
assert "py_modules will not be guessed" in out
assert not err
开发者ID:a-tal,项目名称:pypackage,代码行数:28,代码来源:test_guessing.py
示例2: test_verify_key__list_object
def test_verify_key__list_object():
"""If an attribute should be a list, it should be listed."""
conf = Config()
conf.foo = "not a list"
conf._verify_key("foo", list)
assert conf.foo == ["not a list"]
开发者ID:a-tal,项目名称:pypackage,代码行数:7,代码来源:test_config.py
示例3: test_verify_key__dict_types
def test_verify_key__dict_types():
"""If a dict is provided with types, the key/values should be coerced."""
conf = Config()
conf.foo = {3.14: "500.123"}
conf._verify_key("foo", {str: float})
assert conf.foo == {"3.14": 500.123}
开发者ID:a-tal,项目名称:pypackage,代码行数:7,代码来源:test_config.py
示例4: test_perform_guesswork__ignore
def test_perform_guesswork__ignore(capfd, reset_sys_argv, move_home_pypackage):
"""If the user responds with 'all', ignore all guesses."""
conf = Config()
conf.name = "previously existing"
sys.argv = ["py-build", "-i"]
guesses = OrderedDict([
("name", "some name"),
("py_modules", "some_thing"),
("scripts", ["bin/something"]),
("package_data", {"some name": ["thing/data/file_1"]}),
])
with mock.patch.object(guessing, "_guess_at_things", return_value=guesses):
with mock.patch.object(guessing, "INPUT", return_value="all"):
guessing.perform_guesswork(conf, get_options())
assert conf.name == "previously existing"
assert not hasattr(conf, "py_modules")
assert not hasattr(conf, "package_data")
assert not hasattr(conf, "scripts")
out, err = capfd.readouterr()
assert "ignoring all guesses" in out
assert not err
开发者ID:a-tal,项目名称:pypackage,代码行数:25,代码来源:test_guessing.py
示例5: test_verify_key__str_list_values
def test_verify_key__str_list_values():
"""If the type is list, the items inside should be strings."""
conf = Config()
conf.foo = ["bar", 3.14, "baz"]
conf._verify_key("foo", list)
assert conf.foo == ["bar", "3.14", "baz"]
开发者ID:a-tal,项目名称:pypackage,代码行数:7,代码来源:test_config.py
示例6: test_verify_key__failure_coerce
def test_verify_key__failure_coerce():
"""Should try to coerce values into their types when not list or dict."""
conf = Config()
conf.foo = 3.14
conf._verify_key("foo", str)
assert conf.foo == "3.14"
开发者ID:a-tal,项目名称:pypackage,代码行数:7,代码来源:test_config.py
示例7: test_standard_attributes__re_classify
def test_standard_attributes__re_classify(reset_sys_argv):
"""If reclassify is set, classifiers should be in the unconfigured set."""
conf = Config()
conf.classifiers = ["fake things"]
sys.argv = ["py-build", "-R"]
attrs = configure.standard_attributes(conf, get_options())
assert "classifiers" in attrs
开发者ID:ccpgames,项目名称:pypackage,代码行数:8,代码来源:test_configure.py
示例8: test_cmdclass_string
def test_cmdclass_string():
"""Ensure the cmdclass string outputting is correct."""
conf = Config(cmdclass={"foo": "MyFooClass", "test": "gets overridden"})
cmdcls_str = conf._cmdclass_string()
assert cmdcls_str.startswith("cmdclass={")
assert "'foo': MyFooClass" in cmdcls_str
assert "'test': PyPackageTest" in cmdcls_str
开发者ID:a-tal,项目名称:pypackage,代码行数:8,代码来源:test_config.py
示例9: test_verify_key__dict_failure
def test_verify_key__dict_failure():
"""Do not try to coerce something that should be a dict into one."""
conf = Config()
conf.foo = "not a dict"
with pytest.raises(TypeError) as error:
conf._verify_key("foo", {})
assert error.value.args[0] == "foo should be a dict, not str!"
开发者ID:a-tal,项目名称:pypackage,代码行数:8,代码来源:test_config.py
示例10: test_malformed_packages_fallback
def test_malformed_packages_fallback():
"""Invalid values using find_packages should fallback to their string."""
garbage = "find_packages([email protected]!^%&)%*_!()$*!*^!%&*(!)[email protected]_!*)"
conf = Config(packages=[garbage])
assert conf.packages == [garbage]
assert conf._as_kwargs.get("packages") == [garbage]
assert conf._packages_string() == ("packages={}".format(garbage), True)
开发者ID:a-tal,项目名称:pypackage,代码行数:8,代码来源:test_config.py
示例11: test_verify_key__failure
def test_verify_key__failure():
"""If unable to coerce into the expected type, raise TypeError."""
conf = Config()
conf.foo = "something"
with pytest.raises(TypeError) as error:
conf._verify_key("foo", float)
assert error.value.args[0] == "foo should be a float, not str!"
开发者ID:a-tal,项目名称:pypackage,代码行数:8,代码来源:test_config.py
示例12: test_feature_attributes
def test_feature_attributes(reset_sys_argv, move_home_pypackage):
"""If we have default runner args they should appear unconfigured."""
conf = Config()
conf.runner_args = ["fake", "args"]
conf._configured_runner_args = False
attrs = configure.feature_attributes(conf, get_options())
expected = list(conf._PYPACKAGE_KEYS.keys())
assert attrs == expected
开发者ID:ccpgames,项目名称:pypackage,代码行数:9,代码来源:test_configure.py
示例13: test_standard_attributes__re_config
def test_standard_attributes__re_config(reset_sys_argv):
"""If reconfig is set, all standard attributes should be unconfigured."""
conf = Config()
conf.name = "something"
sys.argv = ["py-build", "-r"]
attrs = configure.standard_attributes(conf, get_options())
expected = list(conf._KEYS.keys())[:conf._STD_TO_EXTD_INDEX]
assert attrs == expected
开发者ID:ccpgames,项目名称:pypackage,代码行数:9,代码来源:test_configure.py
示例14: test_extended_attributes
def test_extended_attributes(reset_sys_argv, move_home_pypackage):
"""Extended attributes should return unset keys past _STD_TO_EXTD_INDEX."""
conf = Config()
expected = list(conf._KEYS.keys())[conf._STD_TO_EXTD_INDEX:]
conf.use_2to3 = True
expected.remove("use_2to3")
attrs = configure.extended_attributes(conf, get_options())
assert attrs == expected
开发者ID:ccpgames,项目名称:pypackage,代码行数:9,代码来源:test_configure.py
示例15: test_extended_attributes__re_config
def test_extended_attributes__re_config(reset_sys_argv):
"""If --rebuild is used, all extended attributes should be unconfigured."""
conf = Config()
conf.use_2to3 = True
sys.argv = ["py-build", "-r"]
attrs = configure.extended_attributes(conf, get_options())
expected = list(conf._KEYS.keys())[conf._STD_TO_EXTD_INDEX:]
assert attrs == expected
开发者ID:ccpgames,项目名称:pypackage,代码行数:9,代码来源:test_configure.py
示例16: test_feature_attributes__re_config
def test_feature_attributes__re_config(reset_sys_argv):
"""When --rebuild is used, all features should appear unconfigured."""
conf = Config()
conf.test_runner = "pytest"
sys.argv = ["py-build", "--rebuild"]
attrs = configure.feature_attributes(conf, get_options())
expected = list(conf._PYPACKAGE_KEYS.keys())
assert attrs == expected
开发者ID:ccpgames,项目名称:pypackage,代码行数:9,代码来源:test_configure.py
示例17: test_verify_key__multiple__fallthrough
def test_verify_key__multiple__fallthrough():
"""If the first coerce fails, try the second."""
conf = Config()
conf.bar = mock.MagicMock(spec=False)
conf.bar.__float__ = mock.Mock(side_effect=ValueError)
conf.bar.__str__ = mock.Mock(return_value="mock str")
conf._verify_key("bar", (float, str))
assert conf.bar == "mock str"
开发者ID:a-tal,项目名称:pypackage,代码行数:9,代码来源:test_config.py
示例18: test_verify_key__multiple__failure
def test_verify_key__multiple__failure():
"""When unable to coerce to any type, raise TypeError."""
conf = Config()
conf.foo = mock.MagicMock(spec=False)
conf.foo.__float__ = mock.Mock(side_effect=ValueError)
conf.foo.__str__ = mock.Mock(side_effect=ValueError)
with pytest.raises(TypeError) as err:
conf._verify_key("foo", (float, str))
assert err.value.args[0] == "foo should be a float or str, not MagicMock!"
开发者ID:a-tal,项目名称:pypackage,代码行数:10,代码来源:test_config.py
示例19: test_standard_attributes
def test_standard_attributes(reset_sys_argv, move_home_pypackage):
"""Ensure the standard attribute set."""
conf = Config()
expected_attrs = list(conf._KEYS.keys())[:conf._STD_TO_EXTD_INDEX]
conf.name = "foobar"
conf.classifiers = ["fake classifier"]
expected_attrs.remove("name")
expected_attrs.remove("classifiers")
attrs = configure.standard_attributes(conf, get_options())
assert attrs == expected_attrs
开发者ID:ccpgames,项目名称:pypackage,代码行数:11,代码来源:test_configure.py
示例20: test_runner_string__unittest
def test_runner_string__unittest():
"""Ensure the correct template and formatting is used for unittest."""
conf = Config(
test_runner="unittest is the default when provided nonsense",
tests_dir="my_non_std_tests",
)
template_str = conf._test_runner_string()
assert "import unittest" in template_str
assert "my_non_std_tests" in template_str
开发者ID:a-tal,项目名称:pypackage,代码行数:11,代码来源:test_config.py
注:本文中的pypackage.config.Config类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论