mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-23 04:31:33 +08:00
Add some fstring tests.
This commit is contained in:
24
test/test_fstring.py
Normal file
24
test/test_fstring.py
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user