summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorptmcg <ptmcg@austin.rr.com>2021-08-15 20:14:07 -0500
committerptmcg <ptmcg@austin.rr.com>2021-08-15 20:14:07 -0500
commitb816a806ec1dbcb7f6a1e8a0bfadd42afa9eb64b (patch)
tree19a976d6519fd210b497ce8b00d058fee39b0ccb /tests
parent9149fcb5f95873627e328b32c739740efb2aa9fb (diff)
downloadpyparsing-git-b816a806ec1dbcb7f6a1e8a0bfadd42afa9eb64b.tar.gz
Additional unit tests for IndentedBlock, with bad indented code and indented code that skips unindent levels
Diffstat (limited to 'tests')
-rw-r--r--tests/test_unit.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test_unit.py b/tests/test_unit.py
index ff2df40..1b44af9 100644
--- a/tests/test_unit.py
+++ b/tests/test_unit.py
@@ -6642,6 +6642,31 @@ class Test02_WithoutPackrat(ppt.TestParseResultsAsserts, TestCase):
[["A", [100, 101, 102]], ["B", [["b", [200, 201]]]], ["C", [300]]],
)
+ print("using parseString")
+ print(group[...].parseString(data).dump())
+
+ print("test bad indentation")
+ dotted_int = pp.delimited_list(
+ pp.Word(pp.nums), ".", allow_trailing_delim=True, combine=True
+ )
+ indented_expr = pp.IndentedBlock(dotted_int, recursive=True)
+ good_data = """\
+ 1.
+ 1.1
+ 1.1.1
+ 2."""
+ bad_data = """\
+ 1.
+ 1.1
+ 1.1.1
+ 1.2
+ 2."""
+ indented_expr.parseString(good_data, parseAll=True)
+ with self.assertRaisesParseException(
+ msg="Failed to raise exception with bad indentation"
+ ):
+ indented_expr.parseString(bad_data, parseAll=True)
+
def testInvalidDiagSetting(self):
with self.assertRaises(
ValueError,