From 0c0a4b5a5d40de8f6d777f2ea900eded90c4c022 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Thu, 24 Aug 2017 01:39:28 +0200 Subject: [PATCH] Add some fstring tests. --- test/test_fstring.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/test_fstring.py diff --git a/test/test_fstring.py b/test/test_fstring.py new file mode 100644 index 0000000..1b06743 --- /dev/null +++ b/test/test_fstring.py @@ -0,0 +1,24 @@ +import pytest + +from parso import load_grammar + + +@pytest.fixture +def grammar(): + return load_grammar(language="python-f-string") + + +@pytest.mark.parametrize( + 'code', [ + '{1}', + '', + '{1!a}', + '{1!a:1}', + '{1:1}', + '{1:1.{32}}', + ] +) +def test_valid(code, grammar): + fstring = grammar.parse(code, error_recovery=False) + assert fstring.type == 'fstring' + assert fstring.get_code() == code