Beispiel #1
0
 def test_no_toml_installed(self, temp_dir):
     # Without toml installed, raise an error if we have settings in the toml
     # file.
     (temp_dir / "pyproject.toml").write_text(TOML_CONFIG)
     with without_module(scriv.config, "tomli"):
         msg_pat = r"Can't read .* without TOML support"
         with pytest.raises(Exception, match=msg_pat):
             Config.read()
Beispiel #2
0
 def test_no_toml_installed_no_settings(self, temp_dir):
     # Without toml installed, and also none of our settings in the toml
     # file, there is no exception.
     (temp_dir / "pyproject.toml").write_text(GENERIC_TOML_CONFIG)
     with without_module(scriv.config, "tomli"):
         config = Config.read()
     assert config.categories[0] == "Removed"
Beispiel #3
0
def test_reading_config_from_other_directory(temp_dir):
    # setup.cfg can set the fragment directory, and then scriv.ini will
    # be found there.
    (temp_dir / "scriv.d").mkdir()
    (temp_dir / "scriv.d" / "scriv.ini").write_text(CONFIG1)
    (temp_dir /
     "setup.cfg").write_text("[tool.scriv]\nfragment_directory = scriv.d\n")
    config = Config.read()
    assert config.fragment_directory == "scriv.d"
    assert config.categories == ["New", "Different", "Gone", "Bad"]
Beispiel #4
0
 def test_toml_without_us(self, temp_dir):
     (temp_dir / "pyproject.toml").write_text(GENERIC_TOML_CONFIG)
     config = Config.read()
     assert config.categories == [
         "Removed",
         "Added",
         "Changed",
         "Deprecated",
         "Fixed",
         "Security",
     ]
Beispiel #5
0
def test_defaults(temp_dir):
    # No configuration files anywhere, just get all the defaults.
    config = Config.read()
    assert config.fragment_directory == "changelog.d"
    assert config.format == "rst"
    assert config.new_fragment_template.startswith(
        ".. A new scriv changelog fragment")
    assert config.categories == [
        "Removed",
        "Added",
        "Changed",
        "Deprecated",
        "Fixed",
        "Security",
    ]
    assert config.output_file == "CHANGELOG.rst"
    assert config.insert_marker == "scriv-insert-here"
    assert config.rst_header_chars == "=-"
    assert config.md_header_level == "1"
    assert "{{ date.strftime('%Y-%m-%d') }}" in config.entry_title_template
    assert config.main_branches == ["master", "main", "develop"]
    assert config.version == ""
Beispiel #6
0
def test_reading_config(temp_dir):
    (temp_dir / "setup.cfg").write_text(CONFIG1)
    config = Config.read()
    assert config.fragment_directory == "changelog.d"
    assert config.output_file == "README.md"
    assert config.categories == ["New", "Different", "Gone", "Bad"]
Beispiel #7
0
 def test_reading_toml_file(self, temp_dir):
     (temp_dir / "pyproject.toml").write_text(TOML_CONFIG)
     config = Config.read()
     assert config.categories == ["New", "Different", "Gone", "Bad"]
Beispiel #8
0
def test_md_format(changelog_d):
    (changelog_d / "scriv.ini").write_text("[scriv]\nformat = md\n")
    config = Config.read()
    assert config.output_file == "CHANGELOG.md"
    template = re.sub(r"\s+", " ", config.new_fragment_template)
    assert template.startswith("<!-- A new scriv changelog fragment.")
Beispiel #9
0
def test_unknown_option():
    config = Config.read()
    expected = "Scriv configuration has no 'foo' option"
    with pytest.raises(AttributeError, match=expected):
        config.foo  # pylint: disable=pointless-statement
Beispiel #10
0
def test_reading_config_from_directory(changelog_d):
    # The settings file can be changelog.d/scriv.ini .
    (changelog_d / "scriv.ini").write_text(CONFIG1)
    config = Config.read()
    assert config.categories == ["New", "Different", "Gone", "Bad"]
Beispiel #11
0
def test_reading_config_list(temp_dir):
    (temp_dir / "tox.ini").write_text(CONFIG2)
    config = Config.read()
    assert config.categories == ["New", "Different", "Gone", "Bad"]