A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/nedbat/coveragepy/issues/996 below:

Excluding multiple lines with exclude_lines · Issue #996 · nedbat/coveragepy · GitHub

As far as I can tell, it isn't posible to exclude multiple lines with exclude_lines. If I am reading the code correctly, it uses the lines_matching function, which checks the regexes line-by-line

def lines_matching(self, *regexes): """Find the lines matching one of a list of regexes. Returns a set of line numbers, the lines that contain a match for one of the regexes in `regexes`. The entire line needn't match, just a part of it. """ combined = join_regex(regexes) if env.PY2: combined = combined.decode("utf8") regex_c = re.compile(combined) matches = set() for i, ltext in enumerate(self.lines, start=1): if regex_c.search(ltext): matches.add(i) return matches

My use-case is I want to exclude lines like

except ValueError: 
    assume(False)

where assume is from hypothesis. Simply excluding assume(False) doesn't work because it doesn't exclude the except. I don't want to exclude other except ValueError blocks in the codebase. I know I can rewrite this as except ValueError: assume(False) on a single line, but I would prefer not to as I don't like code that does that.

What I would like to do is to write something like

[report]
exclude_lines = 
    except ValueError:\n *assume\(False\)

Or if that can't work

[report]
exclude_lines = 
    except ValueError:(?=\n *assume\(False\))

Neither of these work presently. As far as I can tell this can only be excluded by manually putting # pragma: no cover on each instance.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4