Small test refactoring, because not all fstrings errors from parso match the CPython equivalents.

This commit is contained in:
Dave Halter
2017-08-26 19:18:16 +02:00
parent 66606403c7
commit cba82773d4
2 changed files with 14 additions and 1 deletions

View File

@@ -152,7 +152,6 @@ FAILING_EXAMPLES = [
"f'{\"}'",
"f'{\"}'",
# Now nested parsing
"f'{1+}'",
"f'{continue}'",
"f'{1;1}'",
"f'{a=3}'",

View File

@@ -246,3 +246,17 @@ def test_too_many_levels_of_indentation():
)
def test_valid_fstrings(code):
assert not _get_error_list(code, version='3.6')
@pytest.mark.parametrize(
('code', 'message'), [
("f'{1+}'", ('invalid syntax')),
]
)
def test_invalid_fstrings(code, message):
"""
Some fstring errors are handled differntly in 3.6 and other versions.
Therefore check specifically for these errors here.
"""
error, = _get_error_list(code, version='3.6')
assert message in error.message