Running coverage report
in a directory with no .coverage creates it · Issue #1328 · nedbat/coveragepy (original) (raw)
Describe the bug
Running coverage report
creates a .coverage
file even if it didn't exist before.
To Reproduce
- What version of Python are you using? 3.9
- What version of coverage.py shows the problem? 6.3.2 coverage debug sys
-- sys -------------------------------------------------------
coverage_version: 6.3.2
coverage_module: /home/mg/.local/pipx/venvs/coverage/lib/python3.9/site-packages/coverage/__init__.py
tracer: -none-
CTracer: available
plugins.file_tracers: -none-
plugins.configurers: -none-
plugins.context_switchers: -none-
configs_attempted: .coveragerc
setup.cfg
tox.ini
pyproject.toml
configs_read: -none-
config_file: None
config_contents: -none-
data_file: -none-
python: 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
platform: Linux-5.13.0-28-generic-x86_64-with-glibc2.34
implementation: CPython
executable: /home/mg/.local/pipx/venvs/coverage/bin/python
def_encoding: utf-8
fs_encoding: utf-8
pid: 589169
cwd: /home/mg/Private/tilaajavastuu/bol-data-api
path: /home/mg/.local/pipx/venvs/coverage/bin
/usr/lib/python39.zip
/usr/lib/python3.9
/usr/lib/python3.9/lib-dynload
/home/mg/.local/pipx/venvs/coverage/lib/python3.9/site-packages
/home/mg/.local/pipx/shared/lib/python3.9/site-packages
environment: HOME = /home/mg
PYTHONSTARTUP = /home/mg/.python
command_line: /home/mg/.local/bin/coverage debug sys
sqlite3_version: 2.6.0
sqlite3_sqlite_version: 3.35.5
sqlite3_temp_store: 0
sqlite3_compile_options: COMPILER=gcc-10.3.0; ENABLE_COLUMN_METADATA; ENABLE_DBSTAT_VTAB
ENABLE_FTS3; ENABLE_FTS3_PARENTHESIS; ENABLE_FTS3_TOKENIZER
ENABLE_FTS4; ENABLE_FTS5; ENABLE_JSON1
ENABLE_LOAD_EXTENSION; ENABLE_MATH_FUNCTIONS; ENABLE_PREUPDATE_HOOK
ENABLE_RTREE; ENABLE_SESSION; ENABLE_STMTVTAB
ENABLE_UNLOCK_NOTIFY; ENABLE_UPDATE_DELETE_LIMIT; HAVE_ISNAN
LIKE_DOESNT_MATCH_BLOBS; MAX_SCHEMA_RETRY=25; MAX_VARIABLE_NUMBER=250000
OMIT_LOOKASIDE; SECURE_DELETE; SOUNDEX
TEMP_STORE=1; THREADSAFE=1; USE_URI
- What versions of what packages do you have installed? pipx runpip coverage freeze
coverage==6.3.2
coverage-python-version==0.2.0
pkg_resources==0.0.0
- What code shows the problem? no code necessary
- What commands did you run?
$ mkdir /tmp/empty
$ cd /tmp/empty
$ coverage report
No data to report.
$ ls -A
.coverage
Expected behavior
No .coverage
file is created by read-only coverage
subcommands such as report
or xml
Additional context
I have a Vim plugin that looks for the existence of .coverage
files to determine the right directory to run coverage report
. If I accidentally manually run coverage report
in the wrong directory, my tooling breaks (finds the wrong .coverage
file and then reports that all the code is not covered.) It took me a while to realize what the problem was, after all the plugin worked fine before! ;)