summaryrefslogtreecommitdiff
path: root/tests/helpers.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-10-28 06:59:03 -0400
committerNed Batchelder <ned@nedbatchelder.com>2021-10-28 06:59:03 -0400
commit81a55d102550b4535191756960f6846083fc7e30 (patch)
tree0f61064078496ac483e5d03b23800e2f1b95513a /tests/helpers.py
parente36475a387b734711fbbe84c0fe4b6d0777cd9ec (diff)
downloadpython-coveragepy-git-81a55d102550b4535191756960f6846083fc7e30.tar.gz
refactor(test): make re_lines (et al) look like re.search
and also replace some calls with just-plain re.search.
Diffstat (limited to 'tests/helpers.py')
-rw-r--r--tests/helpers.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/helpers.py b/tests/helpers.py
index 7e6594ac..82d8b18f 100644
--- a/tests/helpers.py
+++ b/tests/helpers.py
@@ -133,7 +133,7 @@ class CheckUniqueFilenames:
return ret
-def re_lines(text, pat, match=True):
+def re_lines(pat, text, match=True):
"""Return a list of lines selected by `pat` in the string `text`.
If `match` is false, the selection is inverted: only the non-matching
@@ -146,18 +146,18 @@ def re_lines(text, pat, match=True):
return [l for l in text.splitlines() if bool(re.search(pat, l)) == match]
-def re_lines_text(text, pat, match=True):
+def re_lines_text(pat, text, match=True):
"""Return the multi-line text of lines selected by `pat`."""
- return "".join(l + "\n" for l in re_lines(text, pat, match=match))
+ return "".join(l + "\n" for l in re_lines(pat, text, match=match))
-def re_line(text, pat):
+def re_line(pat, text):
"""Return the one line in `text` that matches regex `pat`.
Raises an AssertionError if more than one, or less than one, line matches.
"""
- lines = re_lines(text, pat)
+ lines = re_lines(pat, text)
assert len(lines) == 1
return lines[0]