summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorptmcg <ptmcg@austin.rr.com>2021-09-28 02:24:12 -0500
committerptmcg <ptmcg@austin.rr.com>2021-09-28 02:24:12 -0500
commit47133a6148a0ac34bbda183d250bad2e4ac2490f (patch)
tree5d3cb9576292e15d7385417d2de40bc3d3f4a6a8 /tests
parentd2cb388b1b66a70713d42af3006be17c63fb3a74 (diff)
downloadpyparsing-git-47133a6148a0ac34bbda183d250bad2e4ac2490f.tar.gz
Code cleanup
Diffstat (limited to 'tests')
-rw-r--r--tests/test_unit.py45
1 files changed, 25 insertions, 20 deletions
diff --git a/tests/test_unit.py b/tests/test_unit.py
index cc08702..08cc7c5 100644
--- a/tests/test_unit.py
+++ b/tests/test_unit.py
@@ -3526,7 +3526,8 @@ class Test02_WithoutPackrat(ppt.TestParseResultsAsserts, TestCase):
def testLineStart3(self):
# testing issue #272
- instring = dedent("""
+ instring = dedent(
+ """
a
b
c
@@ -3534,10 +3535,15 @@ class Test02_WithoutPackrat(ppt.TestParseResultsAsserts, TestCase):
e
f
g
- """)
+ """
+ )
print(pp.testing.with_line_numbers(instring))
- alpha_line = pp.LineStart().leaveWhitespace() + pp.Word(pp.alphas) + pp.LineEnd().suppress()
+ alpha_line = (
+ pp.LineStart().leaveWhitespace()
+ + pp.Word(pp.alphas)
+ + pp.LineEnd().suppress()
+ )
tests = [
alpha_line,
@@ -3546,38 +3552,37 @@ class Test02_WithoutPackrat(ppt.TestParseResultsAsserts, TestCase):
alpha_line | alpha_line,
pp.MatchFirst([alpha_line, alpha_line]),
pp.LineStart() + pp.Word(pp.alphas) + pp.LineEnd().suppress(),
- pp.And([pp.LineStart(), pp.Word(pp.alphas), pp.LineEnd().suppress()])
- ]
+ pp.And([pp.LineStart(), pp.Word(pp.alphas), pp.LineEnd().suppress()]),
+ ]
for test in tests:
print(test.searchString(instring))
- self.assertEqual(["a", "d", "e"], flatten(sum(test.search_string(instring)).as_list()))
+ self.assertEqual(
+ ["a", "d", "e"], flatten(sum(test.search_string(instring)).as_list())
+ )
def testLineStart4(self):
- test = dedent('''\
+ test = dedent(
+ """\
AAA this line
AAA and this line
AAA but not this one
B AAA and definitely not this one
- ''')
+ """
+ )
- expr = pp.AtLineStart('AAA') + pp.restOfLine
+ expr = pp.AtLineStart("AAA") + pp.restOfLine
for t in expr.search_string(test):
print(t)
- self.assertEqual(['AAA', ' this line', 'AAA', ' and this line'], sum(expr.search_string(test)).as_list())
+ self.assertEqual(
+ ["AAA", " this line", "AAA", " and this line"],
+ sum(expr.search_string(test)).as_list(),
+ )
def testStringStart(self):
- self.assertParseAndCheckList(
- pp.AtStringStart(pp.Word(pp.nums)),
- "123",
- ["123"]
- )
+ self.assertParseAndCheckList(pp.AtStringStart(pp.Word(pp.nums)), "123", ["123"])
- self.assertParseAndCheckList(
- pp.AtStringStart("123"),
- "123",
- ["123"]
- )
+ self.assertParseAndCheckList(pp.AtStringStart("123"), "123", ["123"])
with self.assertRaisesParseException():
pp.AtStringStart(pp.Word(pp.nums)).parse_string(" 123")