def test_validate_format(setup_cfg_path):
    updater = ConfigUpdater(allow_no_value=False)
    updater.read(setup_cfg_path)
    updater.validate_format()
    updater.set('metadata', 'author')
    with pytest.raises(ParsingError):
        updater.validate_format()
示例#2
0
def test_comments_in_multiline_options():
    updater = ConfigUpdater()
    updater.read_string(test20_cfg_in)
    per_file_ignores = updater["flake8"]["per-file-ignores"].value
    exp_val = (
        "\n# Disable imports in `__init__.py`:\nlambdas/__init__.py: WPS226, WPS413\n"
        "lambdas/contrib/mypy/lambdas_plugin.py: WPS437\n# There are multiple assert's"
        " in tests:\ntests/*.py: S101, WPS226, WPS432, WPS436, WPS450\n# We need to"
        " write tests to our private class:\ntests/test_math_expression/*.py: S101,"
        " WPS432, WPS450")
    updater.validate_format()
    assert per_file_ignores == exp_val
    assert test20_cfg_in == str(updater)
示例#3
0
def test_validate_format_propagates_kwargs(setup_cfg_path):
    updater = ConfigUpdater(allow_no_value=True)
    updater.read(setup_cfg_path)
    updater.set("pyscaffold", "namespace")
    assert updater["pyscaffold"]["namespace"].value is None
    assert str(
        updater["pyscaffold"]["namespace"]) == "namespace\n"  # no `=` sign
    assert updater.validate_format() is True