Bug report
python -m trace --count --no-report --file FILE script.py exits
successfully but never writes FILE, so counts cannot be accumulated
across runs.
Both options are documented for exactly this workflow:
-f, --file FILE — "File to accumulate counts over several runs"
-R, --no-report — "Do not generate the coverage report files. Useful
if you want to accumulate over several runs."
and Doc/library/trace.rst describes --no-report as useful when you
"intend to make several runs with --count, and then produce a single
set of annotated listings at the end."
However the counts are only persisted at the end of
CoverageResults.write_results(), which main() skips entirely under
--no-report:
if not opts.no_report:
results.write_results(opts.missing, opts.summary, opts.coverdir)
So --no-report suppresses the report and the --file counts. The file
is never created, and because --file is also read back at startup, every
run warns about the file it was supposed to accumulate into:
$ cat prog.py
for i in range(3):
pass
$ python -m trace --count --no-report --file counts prog.py
Skipping counts file 'counts': [Errno 2] No such file or directory: 'counts'
$ python -m trace --count --no-report --file counts prog.py
Skipping counts file 'counts': [Errno 2] No such file or directory: 'counts'
counts is never written, so accumulation never happens. The same command
without --no-report does write counts (alongside the .cover report).
Suggested fix
Move the counts-saving step out of write_results() into a small
CoverageResults.save_counts() helper and call it on the --no-report
path as well, so --file is honoured regardless of --no-report.
Linked PRs
Bug report
python -m trace --count --no-report --file FILE script.pyexitssuccessfully but never writes
FILE, so counts cannot be accumulatedacross runs.
Both options are documented for exactly this workflow:
-f, --file FILE— "File to accumulate counts over several runs"-R, --no-report— "Do not generate the coverage report files. Usefulif you want to accumulate over several runs."
and
Doc/library/trace.rstdescribes--no-reportas useful when you"intend to make several runs with
--count, and then produce a singleset of annotated listings at the end."
However the counts are only persisted at the end of
CoverageResults.write_results(), whichmain()skips entirely under--no-report:So
--no-reportsuppresses the report and the--filecounts. The fileis never created, and because
--fileis also read back at startup, everyrun warns about the file it was supposed to accumulate into:
countsis never written, so accumulation never happens. The same commandwithout
--no-reportdoes writecounts(alongside the.coverreport).Suggested fix
Move the counts-saving step out of
write_results()into a smallCoverageResults.save_counts()helper and call it on the--no-reportpath as well, so
--fileis honoured regardless of--no-report.Linked PRs