def test_generate_file_verbose_template_syntax_error(env, expected_msg_regex) -> None:
    """Verify correct exception raised on syntax error in file before generation."""
    with pytest.raises(TemplateSyntaxError) as exception:
        generate.generate_file(
            project_dir=".",
            infile='tests/files/syntax_error.txt',
            context={'syntax_error': 'syntax_error'},
            env=env,
        )
    assert expected_msg_regex.match(str(exception.value))
Verify correct exception raised on syntax error in file before generation.
tests/test_generate_file.py