File: error_test.py

package info (click to toggle)
python-tatsu 5.13.1%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 892 kB
  • sloc: python: 10,202; makefile: 54
file content (26 lines) | stat: -rw-r--r-- 616 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from __future__ import annotations

from tatsu.exceptions import GrammarError
from tatsu.tool import parse


def test_missing_rule():
    grammar = """
        @@grammar::TestGrammar
          block = test ;
    """
    try:
        parse(grammar, 'abc')
    except GrammarError as e:
        assert str(e) == 'Unknown rules, no parser generated:\ntest'


def test_missing_rules():
    grammar = """
        @@grammar::TestGrammar
          block = test | test2;
    """
    try:
        parse(grammar, 'abc')
    except GrammarError as e:
        assert str(e) == 'Unknown rules, no parser generated:\ntest\ntest2'