I have an error that pants is seemingly complainin...
# general
h
I have an error that pants is seemingly complaining about not having
pytest
? More details in thread
Copy code
23:58:33.09 [ERROR] Completed: Run Pytest - astranis-python/<REDACTED>:tests failed (exit code 1).
Traceback (most recent call last):
  File "/tmp/process-executionzSZxZH/.cache/pex_root/venvs/3ad0f8096ed09d4b74b6393f05ab9a5d3030620e/ca99f6b407a13d64ad0fe4d244f95a445623f0e3/pex", line 160, in <module>
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'pytest'
Can't seem to reproduce since it happened on one of our CI workers
h
This is running
./pants test
it looks like. That is bewildering. Are you using the default tool lockfile or a custom one (set by
[pytest].lockfile
)?
h
Nah, we have our own generated one after adding this to our toml
Copy code
[pytest]
extra_requirements = ["pytest-cov>=2.12,!=2.12.1,<3.1", "pytest-timeout"]
# Pants generates this lock file for us (when we command it) but we still must
# point to it
lockfile = "pytest_requirements.lock"
And nobody has changed it since it was added
h
K, that all looks sensible... Do you have
pytest
as a
python_requirement
target, e.g. in a
requirements.txt
? That's a common (awkward) pattern to define it both in
[pytest].version
and via
python_requirement
target so that things like MyPy can resolve Pytest. https://github.com/pantsbuild/pants/issues/12449
h
Yeah, we do. We definitely need that until we can convert all of our unit tests over to pants testing. I'd also suspect we'd need it for IDE integrations until Pants has more native support for that.
h
Is it the same version as
[pytest].version
?
h
They're different for some legacy reasons that are probably outdated
h
That's the only thing I could think of as being an issue..The "tool PEX" gets merged with the "user requirements PEX" via
--pex-path
, and I believe it simply goes with the first version of Pytest encountered iirc. If possible, it may be fruitful to sync those two versions. (Ack that we really need https://github.com/pantsbuild/pants/issues/12449)