Load newest grammar in face of a future grammar

This commit is contained in:
A5rocks
2025-08-21 13:22:28 +09:00
parent 23b1cdf73d
commit baa3c90d85
3 changed files with 24 additions and 6 deletions

View File

@@ -4,15 +4,21 @@ from parso import utils
def test_load_inexisting_grammar():
# This version shouldn't be out for a while, but if we ever do, wow!
with pytest.raises(NotImplementedError):
load_grammar(version='15.8')
# The same is true for very old grammars (even though this is probably not
# going to be an issue.
# We support future grammars assuming future compatibility,
# but we don't know how to parse old grammars.
with pytest.raises(NotImplementedError):
load_grammar(version='1.5')
def test_load_grammar_uses_older_syntax():
with pytest.warns():
load_grammar(version='4.0')
def test_load_grammar_doesnt_warn(each_version):
load_grammar(version=each_version)
@pytest.mark.parametrize(('string', 'result'), [
('2', (2, 7)), ('3', (3, 6)), ('1.1', (1, 1)), ('1.1.1', (1, 1)), ('300.1.31', (300, 1))
])