本文整理汇总了Python中pypackage.config.Config类的典型用法代码示例。如果您正苦于以下问题:Python Config类的具体用法?Python Config怎么用?Python Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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"]
示例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}
示例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
示例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"]
示例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"
示例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
示例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
示例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!"
示例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)
示例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!"
示例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
示例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
示例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
示例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