Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_generate_file_verbose_template_syntax_error fixed #1671

Merged
merged 3 commits into from May 29, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions tests/test_generate_file.py
@@ -1,6 +1,7 @@
"""Tests for `generate_file` function, part of `generate_files` function workflow."""
import json
import os
import re

import pytest
from jinja2 import FileSystemLoader
Expand Down Expand Up @@ -114,17 +115,16 @@ def test_generate_file_with_false_condition(env):


@pytest.fixture
def expected_msg():
def expected_msg_regex():
"""Fixture. Used to ensure that exception generated text contain full data."""
msg = (
return re.compile(
'Missing end of comment tag\n'
' File "./tests/files/syntax_error.txt", line 1\n'
' I eat {{ syntax_error }} {# this comment is not closed}'
' {2}File "(.[/\\\\])*tests[/\\\\]files[/\\\\]syntax_error.txt", line 1\n'
' {4}I eat {{ syntax_error }} {# this comment is not closed}'
)
return msg.replace("/", os.sep)


def test_generate_file_verbose_template_syntax_error(env, expected_msg):
def test_generate_file_verbose_template_syntax_error(env, expected_msg_regex):
"""Verify correct exception raised on syntax error in file before generation."""
with pytest.raises(TemplateSyntaxError) as exception:
generate.generate_file(
Expand All @@ -133,7 +133,7 @@ def test_generate_file_verbose_template_syntax_error(env, expected_msg):
context={'syntax_error': 'syntax_error'},
env=env,
)
assert str(exception.value) == expected_msg
assert expected_msg_regex.match(str(exception.value)) is not None
MaciejPatro marked this conversation as resolved.
Show resolved Hide resolved


def test_generate_file_does_not_translate_lf_newlines_to_crlf(env, tmp_path):
Expand Down