#20992 How to enable different version of Pytest with Poetry and resolves
New discussion created by
akomisarek
Hello,
In the older version of pants we could specify the version of pytest in the Pants config:
https://www.pantsbuild.org/2.15/docs/python/goals/test#pytest-version-and-plugins
In recent versions (I think stopping at 2.16) this syntax is no longer supported and we need to rely on the resolvers and install from resolvers.
How do I replicate that setup with Poetry + Pants and how I can provide smaller lockfiles?
1. I can have dev section in my Poetry, where I can add my test dependencies. Can I generate Pants lockfile from this Poetry section somehow easily?
2. I couldn't find answer in that section:
https://www.pantsbuild.org/2.21/docs/python/overview/lockfiles#lockfiles-for-tools
3. I am aware of macro "poetry-requirements." I can even pass "resolver" there, but it would just build me a lockfile with the whole universe of dependencies.
I tried the below:
1. In pants.toml I have:
[python.resolves]
pytest = "pytest_lockfile.txt"
[pytest]
args = ["--disable-warnings"]
install_from_resolve = "pytest"
2. In my pyproject.toml I have:
pytest = "7.3.0"
pytest-datafiles = "2.0.1"
testfixtures = "^7.0.4"
... others
3. In BUILD:
poetry_requirements(name="poetry-dev", resolver="pytest") # I guess here I would need to be able to target only my test dependencies..
4. Lockfile generation, generate all the dependencies from the project, which is not what I should use, is it? I would expect just the version of libraries and dependencies for pytest itself
pants generate-lockfiles --resolve=pytest
Any recommendations?
Thanks!
pantsbuild/pants