@@ -1914,6 +1914,32 @@ def test_export_changelog_template_from_plugin(
19141914 assert target .read_text () == tpl
19151915
19161916
1917+ def test_export_changelog_template_fails_when_template_has_no_filename (
1918+ mocker : MockFixture ,
1919+ tmp_commitizen_project : Path ,
1920+ ):
1921+ project_root = Path (tmp_commitizen_project )
1922+ target = project_root / "changelog.jinja"
1923+ 1924+ # Mock a template object with no filename
1925+ class FakeTemplate :
1926+ filename = None
1927+ 1928+ # Patch get_changelog_template to return a template without a filename
1929+ mocker .patch (
1930+ "commitizen.changelog.get_changelog_template" , return_value = FakeTemplate ()
1931+ )
1932+ 1933+ args = ["cz" , "changelog" , "--export-template" , str (target )]
1934+ mocker .patch .object (sys , "argv" , args )
1935+ 1936+ with pytest .raises (NotAllowed ) as exc_info :
1937+ cli .main ()
1938+ 1939+ assert not target .exists ()
1940+ assert "Template filename is not set" in str (exc_info .value )
1941+ 1942+ 19171943@skip_below_py_3_13
19181944def test_changelog_command_shows_description_when_use_help_option (
19191945 mocker : MockFixture , capsys , file_regression
0 commit comments