summaryrefslogtreecommitdiff
path: root/tests/test_diagram.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_diagram.py')
-rw-r--r--tests/test_diagram.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/tests/test_diagram.py b/tests/test_diagram.py
index a449bb0..eeb1ee8 100644
--- a/tests/test_diagram.py
+++ b/tests/test_diagram.py
@@ -4,6 +4,7 @@ from examples.simpleBool import boolExpr
from examples.simpleSQL import simpleSQL
from examples.mozillaCalendarParser import calendars
from pyparsing.diagram import to_railroad, railroad_to_html
+from pyparsing import Or
import tempfile
import os
@@ -26,26 +27,29 @@ class TestRailroadDiagrams(unittest.TestCase):
def test_bool_expr(self):
with self.get_temp() as temp:
railroad = to_railroad(boolExpr)
+ assert len(railroad) == 3
temp.write(railroad_to_html(railroad))
if self.railroad_debug():
- print(temp.name)
+ print("bool expr:" + temp.name)
def test_json(self):
with self.get_temp() as temp:
railroad = to_railroad(jsonObject)
+ assert len(railroad) == 4
temp.write(railroad_to_html(railroad))
if self.railroad_debug():
- print(temp.name)
+ print("json: " + temp.name)
def test_sql(self):
with self.get_temp() as temp:
railroad = to_railroad(simpleSQL)
+ assert len(railroad) == 7
temp.write(railroad_to_html(railroad))
if self.railroad_debug():
- print(temp.name)
+ print("sql: " + temp.name)
def test_calendars(self):
with self.get_temp() as temp:
@@ -53,4 +57,10 @@ class TestRailroadDiagrams(unittest.TestCase):
temp.write(railroad_to_html(railroad))
if self.railroad_debug():
- print(temp.name)
+ print("calendar: " + temp.name)
+
+ def test_none_name(self):
+ grammar = Or(["foo", "bar"])
+ railroad = to_railroad(grammar)
+ assert len(railroad) == 1
+ assert railroad[0].name is not None