Skip to content

Fix example regex for pytest-cov

Stephen Rosen requested to merge sirosen/gitlab:fix-pytest-cov-regex into master

Fix the documentation example for a regex for pytest-cov coverage reporting to avoid an unnecessary case-insensitivity qualifier which causes the regex to fail to compile in most languages/engines. This improves the ability of downstream validators to validate typical (per the docs) .gitlab-ci.yaml files as containing well-formed regexes in this location, e.g., the validation under the gitlab-ci JSON Schema with a "format"-respecting JSON Schema validator.

Resolves #441181 (closed)


Upon review, I found that there was no true reason to apply case-insensitivity to this string. coverage has effectively always output all-caps TOTAL, and there's no reason to expect this to change after a very long history with fairly consistent string formats.

For reference, I did some git-blame hunting and found the first commit on GitHub in which coverage provided TOTAL in its output, 16 years ago. https://github.com/nedbat/coveragepy/commit/0cc8fd18714cb214327a0a58b704401a9efdf8dc

Therefore, in a deviation from the original issue report, I have not made the regex use [Tt][Oo][Tt][Aa][Ll], but TOTAL instead. This reads better for the typical user, and should have no negative impact.

Merge request reports