Repository navigation
Releases
7.18.0
Version 7.18.0 — 2026-11-29
- Feature:
[run] source(and--source) entries can now be glob patterns, for examplepackages/*/src. A pattern is expanded to the directories it matches when measurement starts, so monorepo packages are measured, and their un-executed files reported, without listing each one. A pattern that matches nothing issues a warning. Closes issue 2400. - Feature: two new methods for plug-ins to use in their test suites, as requested in issue 920. The Coverage.get_plugins() method returns the currently registered plug-ins, including disabled ones. The CoveragePlugin.is_enabled() method reports their current enabled state.
- Fix:
lcovoutput now marks functions as starting on the first non-signature line, fixing errors about “inconsistent” tracefiles during combination. Closed issue 2394. - Fix: XML and LCOV reports now honor the report context filter when calculating coverage.
- Fix: when two source roots each contained a package with the same name, the XML report kept only one of the same-named files while still counting the lines of both, so
lines-validdisagreed with the<line>elements in the document. Closes issue 1291. - Fix: with
[html] show_contextsenabled, re-running the HTML report kept pages whose lines were unchanged, even when the contexts were different, so they showed stale contexts. Closes issue 2372. - Fix: with the C tracer and branch coverage, an error while starting to trace a function call (for example,
RecursionErrorfromshould_tracewhen a new file is entered near the recursion limit) left the previous call’s file in place. If the exception was caught, the function’s return recorded arcs in that other file, which could report lines as executed that never ran. Now a call that fails to start records nothing, closing issue 2385. - Fix: missing branch explanations for exits from a
finallyclause could incorrectly say a condition was always true, even when it was false while an exception or return was pending. These explanations now describe the missing jump without attributing it solely to the condition. Fixes issue 867. - Fix: if a directory for the data file or a report couldn’t be created, the error was a raw traceback. Now the error message names the file that was being written.
- Perf: line coverage reports are faster when many measurement contexts cover the same file.
➡️ PyPI page: coverage 7.18.0.
➡️ To install: python3 -m pip install coverage==7.18.0
7.17.5
Version 7.17.5 — 2026-11-23
- Fix: the reporting commands (
report,html,xml,json,lcov, andannotate) used to put the current directory first onsys.path, to let plugins import local files. Now the current directory is added only if plugins are configured, and at the end ofsys.path, so local files can’t replace other modules. - Fix: local plugins interfered with
eraseandcombineas reported in issue 1726 and issue 1979. This is now fixed (pull 2253). - Fix: with the sysmon core on Python 3.14, starting and stopping a second Coverage object stopped the first one from measuring code it had already run. Closes issue 2302.
- Fix: combining data files failed with “Conflicting file tracer name” when one data file only listed a file without measuring it (as unexecuted source files are) and another measured the same file with a plugin. This happened in pytest-cov’s distributed testing. Now a file with no measurements doesn’t conflict with a plugin’s measurements. Fixes issue 2358.
- Fix: saving data while another thread started measuring a new file handled by a plugin could fail with “dictionary changed size during iteration”. Fixed in pull 2382.
- Fix: a keyboard interrupt at just the wrong moment could leave a lock locked and prevent saving data, as reported in issue 2383. This is now fixed (pull 2396).
➡️ PyPI page: coverage 7.17.5.
➡️ To install: python3 -m pip install coverage==7.17.5
7.17.4
Version 7.17.4 — 2026-11-20
- Fix: since 7.13.1, a parallel data file could be named with the hash of different data than it held, for example when nbval records a notebook’s coverage into pytest-cov’s data file. Combining could then skip it as a duplicate and lose its data. Now the hash comes from the data in the file when it is saved. Fixes issue 2370 with pull 2387.
- Fix: lines or arcs recorded by other threads while data was being flushed (for example during
Coverage.get_data(),Coverage.save(), or dynamic context switches) could be lost. This is now fixed, closing issue 2384. - Fix: on Python 3.14 with the pure-Python tracer (
COVERAGE_CORE=pytrace) and branch measurement, a function that returned right after anexcept*handler recorded an arc with no line number. Reporting on the data then failed with aTypeError. Now that arc is not recorded. pull 2403. - Fix: in the JSON report with
show_contexts, each function and class had the contexts for every line in the file. Now they only have the contexts for their own lines. Closes issue 2374. - The first entry in a
[paths]list is the result path, and must be an actual file path. If it contained wildcards, the rule could never be used and was silently ignored. It is now reported as a configuration error. Closes issue 1531. - Fix: a configuration file (
.coveragerc,setup.cfg,tox.iniorpyproject.toml) saved with a UTF-8 byte order mark couldn’t be read. Now a leading BOM is ignored. pull 2388.
➡️ PyPI page: coverage 7.17.4.
➡️ To install: python3 -m pip install coverage==7.17.4
7.17.3
Version 7.17.3 — 2026-11-11
- Fix: using
patch = fork, a child process wasn’t measured unlesspatch = subprocesswas also used, as described in issue 2340. This is now fixed in pull 2342. - Fix: the JSON report keys functions and classes by name, but names can repeat, for example a property getter and setter. Only the last one was kept, so the others were missing from the report. Now repeated names get a
@<line number>suffix, as in the LCOV report. pull 2353. - Fix: when combining parallel data files, a file that disappears after it has been listed (for example, when the process writing it is still finishing its write) is now reported with a warning, instead of stopping the combine with a
DataError. This was a regression in 7.17.1. Closes issue 2364. - Fix: with
patch = subprocesson Python 3.13, a measured subprocess that was stopped with SIGINT would exit with status 1 instead of dying from the signal. This was a regression in 7.17.1, and is now fixed, closing issue 2362. - Performance: on Python 3.13 and later, using the C tracer should result in test suites running about 8% to 12% faster (pull 2371).
➡️ PyPI page: coverage 7.17.3.
➡️ To install: python3 -m pip install coverage==7.17.3
7.17.2
Version 7.17.2 — 2026-11-04
- Fix: two different scenarios failed with “attempt to write a readonly database”. These were regressions in 7.17.1. They are fixed, closing issue 2356:
- When using a version of SQLite older than 3.34.0, such as on RHEL 8 or Ubuntu 20.04,
coverage combine(and pytest-cov, which combines automatically) always failed. coverage combineandcoverage debug datafailed when a data file existed but had no coverage schema, for example an empty file left behind by a worker that died. A file we can’t read is now reported like any other unusable data file, and is left in place.
- When using a version of SQLite older than 3.34.0, such as on RHEL 8 or Ubuntu 20.04,
➡️ PyPI page: coverage 7.17.2.
➡️ To install: python3 -m pip install coverage==7.17.2
7.17.1
Version 7.17.1 — 2026-11-03
- Fix: a one-line class or function body immediately followed by another statement (such as
class Foo: ...on its own line) was incorrectly reported as a missing branch when using the sys.monitoring core. This is now fixed, closing issue 2167 and issue 2337. - Fix: the HTML report only rewrites a file’s page when the file or its data has changed, but each page also links to the previous and next files. When the set of reported files changed, unchanged pages kept their old links. For example, with
skip_covered, a file that became 100% covered had its page deleted, but the pages next to it still linked to it. Now a page is also rewritten when its neighbors change. - Fix:
--fail-undernow uses at least the decimal precision of the threshold for both the comparison and failure message. Withprecision=0, a total of 0.4 now passes--fail-under=0.3and fails--fail-under=0.5with the message “total of 0.4 is less than fail-under=0.5”. Previously, the comparison rounded the total to zero and the message could claim “1 is less than 0”. Closes issue 2295. - Fix: the HTML report escaped file names twice, so a name with
&,<, or quotes in it was shown with entities like&. Now they are properly escaped only once. - Fix:
--source=/measured no files. A file system root can’t be a source directory, so now it is an error. Closes issue 2291. - In an abundance of caution, prevent forged SQLite journal files from deleting files they shouldn’t.
➡️ PyPI page: coverage 7.17.1.
➡️ To install: python3 -m pip install coverage==7.17.1
7.17.0
Version 7.17.0 — 2026-10-22
- Dropped support for Python 3.10.
- Binary wheels are now provided for iOS and Android. This allows the use of the optimized C tracer on mobile platforms.
- Fix: three or more levels of nested
withstatements could make awithline look like a branch with an exit that can never happen. Using the sys.monitoring core, these phantom branches were reported as partial. Other cores hid the problem but still counted the phantom branches in the total. Closes issue 1987. - Fix: a comment or string that merely mentioned
if True:orwhile True:could mark its line as a branch that is known to be partial, so a branch that never ran was reported as taken. These built-in patterns now only match at the start of the statement. Closes issue 2314. - Fix: region detection missed functions defined in unusual places, such as
elseandexceptclauses. This is now fixed. - Fix: recent versions of the lcov tool complain if the same function name appears more than once in a report. Python can have multiple same-named functions in a few ways, for example, getters/setters or conditionally defined functions. These are now disambiguated by adding a
@<line number>suffix to the function name. Fixes issue 2335. - Fix: The “Can’t combine statement coverage data with branch data” error now names the two data files it couldn’t combine. The error description in the docs now lists common causes and how to find the process that wrote the file.
- Fix: at coverage totals close to 0 or 100, the XML report could get incorrect
line-ratevalues like8.333e-05or1. This is now fixed, closing issue 2293 and issue 2294. - Fix: a parallel data file saved more than once kept the hash of its first save in its file name. Combining could then skip it as a duplicate of another file that had the same data at that point, and delete it, losing the data recorded after the first save. Each save now updates the hash. This had been a problem since 7.13.1. Fixes issue 2338.
- Fixes for obscure but legal file names:
- File names (and plugin names) can contain control characters, which are legal in POSIX paths but unsafe in reports: in XML 1.0 they make the document non-well-formed, and in a terminal they act as escape sequences (colors, title/clipboard sequences, cursor moves that forge output). Now the XML report, the text and Markdown summary reports, and
coverage debug datareplace non-printable characters in names. Printable names are unchanged. - A file pattern (from
include,omit, or a[paths]alias) containing a newline sent the glob-to-regex translation into an infinite loop, hanging the process. Newlines in patterns are now handled like any other character.
- File names (and plugin names) can contain control characters, which are legal in POSIX paths but unsafe in reports: in XML 1.0 they make the document non-well-formed, and in a terminal they act as escape sequences (colors, title/clipboard sequences, cursor moves that forge output). Now the XML report, the text and Markdown summary reports, and
- Fixes in the implementation of the C tracer:
- If a plugin’s
dynamic_source_filenamemethod raised an exception, lines in that function could be recorded as belonging to a different file. Also fixed some minor memory leaks in the C tracer. - The refcount of
Nonewas mismanaged during function calls, including comprehensions. This was unlikely to cause an actual problem, but is now fixed. Thanks, Andrew Dalke. - The C tracer held borrowed references to dictionary values, which was unsafe on free-threaded Python. Now it takes its own references.
- An internal error while recording a new file could be reported as a confusing
SystemErrorinstead of the actual exception.
- If a plugin’s
- Performance: the text summary report (
coverage report) held on to every file’s parsed source until it finished, so its memory use grew with the size of the project: ten times or more what 7.14 used on large projects. Now it keeps only what it needs to print. Fixes issue 2277. - Performance: HTML reports should be about 5% faster to produce.
- Kept the political banner in the README. Closes issue 2344.
➡️ PyPI page: coverage 7.17.0.
➡️ To install: python3 -m pip install coverage==7.17.0
7.16.2
Version 7.16.2 — 2026-09-27
- Fix: on Python 3.14 and later, a
forloop completing immediately before a function return could mistakenly report an uncovered branch. This is now fixed, closing issue 2168. - Fix: on Python 3.14 and later, the
elseclause of atrywhose body is awithstatement could incorrectly be reported as covered when thewithraised. This is now fixed, closing issue 2289. - Fix: with
dynamic_context = test_function, test methods written as@staticmethodor@classmethodwere not given a context of their own. Now they are, on Python 3.11 and later. Closes issue 1923.
➡️ PyPI page: coverage 7.16.2.
➡️ To install: python3 -m pip install coverage==7.16.2
7.16.1
Version 7.16.1 — 2026-09-13
- Fix: when the body of an irrefutable
case(likecase _:) is entirely excluded, thecaseline is now excluded too, just as an excludedelse:body removes theelse:line. Previously thecaseline was left behind and reported as missing. Closes issue 1563 with pull 2269. - Fix: using CoverageData.update() twice on an in-memory database would fail, as described in issue 2279. This is now fixed.
- Fix: the Total row in the footer of the HTML report’s index page was recomputed in JavaScript with rounding that could disagree with the total the server rendered in the heading, including showing
100%when coverage was not complete. The footer now clamps values the way the rest of the report does, and when nothing is filtered out it is shown exactly as the server rendered it, so the two can’t disagree. That also keeps rows the report omits (--skip-covereddrops fully covered files) in the total. Fixes issue 2256.
➡️ PyPI page: coverage 7.16.1.
➡️ To install: python3 -m pip install coverage==7.16.1
7.16.0
Version 7.16.0 — 2026-08-28
- When combining files, now path separator slashes will automatically be converted to the local file system style. This makes it less necessary to define
[paths]configuration to combine data across operating systems. Fixes issue 2266. - The Coverage.switch_context() method now returns the previous context.
- Fix: previously, a
[paths]pattern would be replaced everywhere in a file path when it was only meant to be replaced once, in the leading portion of the path. This is now fixed, in pull 2268. - Fixes to validation of options and configuration settings:
- Negative precision settings now always cause useful error messages (pull 2261).
- An invalid regex in the
--contextsoption (or the[report] contextssetting) reported a confusing “Couldn’t use data file …: user-defined function raised exception” error. Now it raises a proper configuration error naming the bad regex, like other regex settings do (pull 2262). - Non-string values in TOML configuration settings now produce a helpful error message instead of a traceback. This affects list settings whose elements aren’t strings (like
omit,exclude_lines, or a[paths]entry), file settings likedata_file, and any wrong-typed value in the[paths]section (pull 2263). coverage runrefuses run-affecting command-line options like--branchalongside--concurrency=multiprocessing, since they can’t reach the subprocesses. The check only recognizedmultiprocessingas the entire option value, so--concurrency=multiprocessing,threadslipped through and failed later with “Can’t combine statement coverage data with branch data”. Each named concurrency library is now properly considered (pull 2270).
- Fix:
coverage annotate -d DIRraised anAssertionErrorif any measured file had an extension other than.py, such as a.pywfile on Windows. The original extension is now restored on the annotated copy (pull 2265).
➡️ PyPI page: coverage 7.16.0.
➡️ To install: python3 -m pip install coverage==7.16.0