summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Milton <ttmigueltt@gmail.com>2020-06-25 08:13:17 +1000
committerGitHub <noreply@github.com>2020-06-24 17:13:17 -0500
commitefb796099fd77d003dcd49df6a75d1dcc19cefb1 (patch)
treedd7b862691bfbad2f2ef7d0ef6c2f17908755cc5 /tests
parente91acdf0d3e405ce4b02d2c4f27c51e223a01b59 (diff)
downloadpyparsing-git-efb796099fd77d003dcd49df6a75d1dcc19cefb1.tar.gz
Diagram improvements IV (#225)
* Add diagram documentation, add more diagram tests, allow more customization of diagrams * Remove accidental edit of unrelated documentation * Add diagram package * Add jinja file to manifest * Add to bdist also * package_data * Railroad improvements * Partial rewrite * Update * Use partials everywhere so we can edit the tree before it's constructed * Rewrite the diagram generator to not duplicate any content; use monospaced font for titles * Small documentation change * Revert back to Python 3.5 type hints, fix a small bug * More diagram fixes * Even more pruning; update docs to use SQL example * Don't check the string value of names now that we don't have to
Diffstat (limited to 'tests')
-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