diff options
-rw-r--r-- | .coveragerc | 27 | ||||
-rw-r--r-- | qtip/collector/parser/grep.py | 5 | ||||
-rw-r--r-- | tests/unit/collector/grep_test.py | 4 | ||||
-rw-r--r-- | tox.ini | 2 |
4 files changed, 34 insertions, 4 deletions
diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000..dfaeae60 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,27 @@ +# .coveragerc to control coverage.py + +[run] +branch = True +source = + qtip + +[report] +# Regexes for lines to exclude from consideration +exclude_lines = + # Have to re-enable the standard pragma + pragma: no cover + + # Don't complain about missing debug-only code: + def __repr__ + if self\.debug + + # Don't complain if tests don't hit defensive assertion code: + raise AssertionError + raise NotImplementedError + + # Don't complain if non-runnable code isn't run: + if 0: + if __name__ == .__main__.: + +ignore_errors = True + diff --git a/qtip/collector/parser/grep.py b/qtip/collector/parser/grep.py index d7ada485..c3274bc2 100644 --- a/qtip/collector/parser/grep.py +++ b/qtip/collector/parser/grep.py @@ -29,5 +29,6 @@ class GrepParser(BaseActor): def grep_in_file(filename, regex): - with open(filename, 'r') as f: - return filter(lambda x: x is not None, [re.search(regex, line) for line in f]) + with open(filename, "r") as outfile: + return filter(lambda x: x is not None, + list(re.finditer(regex, outfile.read(), re.MULTILINE))) diff --git a/tests/unit/collector/grep_test.py b/tests/unit/collector/grep_test.py index e5d5f8c6..2d4079af 100644 --- a/tests/unit/collector/grep_test.py +++ b/tests/unit/collector/grep_test.py @@ -21,7 +21,9 @@ def logfile(data_root): @pytest.mark.parametrize("regex,expected", [ ('not exist', []), ('Lorem (\S+)', [{'groups': ('ipsum',), 'groupdict': {}}]), - ('nisi ut (?P<name>\S+)', [{'groups': ('aliquip',), 'groupdict': {'name': 'aliquip'}}]) + ('nisi ut (?P<name>\S+)', [{'groups': ('aliquip',), 'groupdict': {'name': 'aliquip'}}]), + ('Lorem\s(\w+)\s.+\nconsectetur\s(\w+)\s.+\n', + [{'groups': ('ipsum', 'adipiscing',), 'groupdict': {}}]) ]) def test_grep_in_file(logfile, regex, expected): matches = grep_in_file(logfile, regex) @@ -16,7 +16,7 @@ deps = commands= py.test \ --basetemp={envtmpdir} \ - --cov qtip --cov-report term-missing --cov-report html \ + --cov \ {posargs} setenv= HOME = {envtmpdir} |