grim/pyparser

Finish up our coverage

2016-08-12, Gary Kramlich
1d2ba805c8c7
Parents de59075ea5e7
Children 3bc331e49f6d
Finish up our coverage
--- a/tests/test_parser.py Fri Aug 12 10:48:05 2016 -0500
+++ b/tests/test_parser.py Fri Aug 12 11:04:41 2016 -0500
@@ -96,11 +96,12 @@
"""
def __init__(self, strip):
- Parser.__init__(self, strip=strip)
+ Parser.__init__(self, strip=strip, ignore_blanks=False)
self.data = {'leading': 0, 'trailing': 0}
def process(self, line):
+
if line.lstrip() != line:
self.data['leading'] += 1
@@ -164,3 +165,21 @@
self._test_counts(True, 'whitespace_mixed.txt', 0, 0)
+
+class BlankParser(Parser):
+ def __init__(self, strip):
+ super(BlankParser, self).__init__(strip=strip, ignore_blanks=True)
+
+ self.data = 0
+
+ def process(self, line):
+ if line.strip() == line:
+ self.data += 1
+
+
+class TestIgnoreBlanks(unittest.TestCase):
+ def test_ignore_blanks(self):
+ blanks = parse_file(BlankParser, 'whitespace_single.txt', strip=True)
+
+ self.assertEqual(blanks, 0)
+