summaryrefslogtreecommitdiff
path: root/tests/goldtest.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-10-23 19:01:27 -0400
committerNed Batchelder <ned@nedbatchelder.com>2021-10-23 20:01:48 -0400
commitbd929f953734f3f5d6cf3e0534aa573b44fc45e2 (patch)
treef4acb62cc7983c64dfdf3488e8bc9e82d1c350d4 /tests/goldtest.py
parentc8ac44828eddfcb444dcdcfc7668370054e96cb9 (diff)
downloadpython-coveragepy-git-bd929f953734f3f5d6cf3e0534aa573b44fc45e2.tar.gz
fix(html): fix a few problems with the html report
- highlights weren't showing - anchored lines were not visible - some j/k motions were broken - clicking the big buttons at the top didn't work
Diffstat (limited to 'tests/goldtest.py')
-rw-r--r--tests/goldtest.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/goldtest.py b/tests/goldtest.py
index 6d9ae4b0..57fa5c06 100644
--- a/tests/goldtest.py
+++ b/tests/goldtest.py
@@ -134,12 +134,27 @@ def contains(filename, *strlist):
missing in `filename`.
"""
+ __tracebackhide__ = True # pytest, please don't show me this function.
with open(filename) as fobj:
text = fobj.read()
for s in strlist:
assert s in text, f"Missing content in {filename}: {s!r}"
+def contains_rx(filename, *rxlist):
+ """Check that the file has lines that re.search all of the regexes.
+
+ An assert will be raised if one of the regexes in `rxlist` doesn't match
+ any lines in `filename`.
+
+ """
+ __tracebackhide__ = True # pytest, please don't show me this function.
+ with open(filename) as fobj:
+ lines = fobj.readlines()
+ for rx in rxlist:
+ assert any(re.search(rx, line) for line in lines), f"Missing rx in {filename}: {rx!r}"
+
+
def contains_any(filename, *strlist):
"""Check that the file contains at least one of a list of strings.
@@ -147,6 +162,7 @@ def contains_any(filename, *strlist):
`filename`.
"""
+ __tracebackhide__ = True # pytest, please don't show me this function.
with open(filename) as fobj:
text = fobj.read()
for s in strlist:
@@ -165,6 +181,7 @@ def doesnt_contain(filename, *strlist):
`filename`.
"""
+ __tracebackhide__ = True # pytest, please don't show me this function.
with open(filename) as fobj:
text = fobj.read()
for s in strlist: