I’m trying to enable coverage for python with pant...
# general
a
I’m trying to enable coverage for python with pants however I’m stuck. 1. When I set
use_coverage = true
in
pants.toml
it complains:
[pytest].extra_requirements is missing pytest-cov, which is needed to collect coverage data.
2. Since
pytest-cov
is a new
extra_requirement
for
pytest
, I have to run
./pants generate-lockfiles --resolve=pytest
. Otherwise, it complains with
InvalidLockfileError
. 3. However, when I run
./pants generate-lockfiles --resolve=pytest
, pants does not generate hashes for some dependencies. 4. So when I run
./pants test ::
it starts to complain:
Copy code
ProcessExecutionFailure: Process 'Building pytest.pex from src/python/tests/lockfile_pytest.txt' failed with exit code 1.
stdout:

stderr:
ERROR: Hashes are required in --require-hashes mode, but they are missing from some requirements. Here is a list of those requirements along with the hashes their downloaded archives actually had. Add lines like these to your requirements files to prevent tampering. (If you did not enable --require-hashes manually, note that it turns on automatically when any package has a hash.)
any ideas?
r
What version of pants are you using? I didn’t have to add any extra requirement for enabling coverage.
b
@refined-addition-53644 I suspect that's because you're using the default pants-provided lockfile for pytest, which includes it. Otherwise if you use your own, you have to also add the additional requirements if you want them.
👍 1
h
The “pants does not generate hashes for some dependencies.” sounds like a bug
1
I don’t reproduce this at HEAD
@agreeable-microphone-98219 which version of Pants, and in the resulting lockfile which deps don’t have hashes?
b
@happy-kitchen-89482 I wonder if this is https://github.com/pantsbuild/pants/discussions/16943?
h
coke
Just came here to say that…