From cba82773d404e4cca99ea2b6fd36e8e6cb66c80f Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Sat, 26 Aug 2017 19:18:16 +0200 Subject: [PATCH] Small test refactoring, because not all fstrings errors from parso match the CPython equivalents. --- test/failing_examples.py | 1 - test/test_python_errors.py | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/test/failing_examples.py b/test/failing_examples.py index 64d5cb2..4227679 100644 --- a/test/failing_examples.py +++ b/test/failing_examples.py @@ -152,7 +152,6 @@ FAILING_EXAMPLES = [ "f'{\"}'", "f'{\"}'", # Now nested parsing - "f'{1+}'", "f'{continue}'", "f'{1;1}'", "f'{a=3}'", diff --git a/test/test_python_errors.py b/test/test_python_errors.py index da68b8e..b724a41 100644 --- a/test/test_python_errors.py +++ b/test/test_python_errors.py @@ -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