https://pantsbuild.org/ logo
#general
Title
# general
b

brash-baker-91190

07/07/2022, 2:44 PM
Running into a weird issue with Python code coverage. I'm using Pytest and
pytest-cov
, and am trying to refactor a bit of code to use Python's "walrus operator", introduced in Python 3.8. I'm using Python 3.8.13, my syntax is correct, my tests run and pass, but the coverage reporting fails with the following:
Copy code
10:40:26.59 [ERROR] 1 Exception encountered:

  ProcessExecutionFailure: Process 'Generate Pytest xml coverage report.' failed with exit code 1.
stdout:
Couldn't parse '/tmp/process-executionhBLEdi/build-support/packer_hcl.py' as Python source: 'invalid syntax' at line 23

stderr:
This line is where the walrus operator was introduced. I'm using
pytest-cov
3.0.0, which supports Python 3.10. I see no issues or PRs about this in either Pytest or `pytest-cov`'s repositories. Is it possible that something in how Pants is running things is causing this? Has anybody else seen anything like this? Thanks in advance.
h

hundreds-father-404

07/07/2022, 2:51 PM
b

brash-baker-91190

07/07/2022, 2:57 PM
Ah, probably so... guess I missed this 😕 Out of curiosity, why doesn't this default to using the globally defined interpreter constraints? My expectation is that I would need to override a particular tool's constraints if I didn't want it using the global constraints, not the other way around.
h

hundreds-father-404

07/07/2022, 3:01 PM
perhaps it should. https://github.com/pantsbuild/pants/issues/11137 ponders the problem generally, that the fact individual tests might run w/ different interpreter constraints is the root of the problem
b

brash-baker-91190

07/07/2022, 3:04 PM
gotcha, thanks. In any event, setting a constraint for
coverage-py
does the trick for me 👍
👍 1
10 Views