-
-
Notifications
You must be signed in to change notification settings - Fork 608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pants test using a different module version than it's assigned resolve #20945
Comments
If so, you can set the packaging version in that resolve's lockfile inputs. One convenient way to do this is to add
|
You nailed it! Using Can you think of any way in which I can force this project tests to use the project's resolve pytest or to override the pytest resolve for such tests? I need to keep the rest of the projects with the same pytest setting. Specifying the resolve in the test folder build file like this is not having the expected effect:
|
Unfortunately that is not currently possible - the resolve that pytest runs from is set globally. However this is a much-requested feature in the New Python Backend discussions. Feel free to chime in there. For now, probably best is to generate a custom pytest lockfile that pins This is an unfortunate problem with pytest - it loads the code under test into the same namespace as its own code. Really, it should "shade" itself and its dependencies. |
Thanks a lot for your guidance was very valuable. We got everything working following your advice |
Glad to hear it! Hopefully in the future this will be handled more smoothly. |
I have a test that depends on the
packaging
module. The resolvepython_rasa
haspackaging<=21.3
in its requirements3rdparty/requirements/python_rasa.txt
and its lock-file"version": "20.9"
for packaging.The BUILD file in project's root folder overrides the resolve to
python_rasa
:As a redundancy, I also pointed out the resolve for the test despite the BUILD in the project's root folder should be enough:
Finally, the current test file is currently just printing the
packaging
version aspants run
runs just fine andpants test
fails due to a packaging version problem on the real test.pants test projects/chatbot/tests/::
printsPackaging version: 23.0
failing withImportError: cannot import name 'LegacyVersion' from 'packaging.version'
; class that is deprecated after packaging 21.3. The logs show thatpants test
builds 3rdparty/lockfiles/python_rasa.lock, which are the correct ones with packaging version 20.9.Curiously enough,
pants run projects/chatbot/tests/test_packaging.py
printsPackaging version: 20.9
passing the test.pants dependencies --transitive projects/chatbot/tests/test_packaging.py
would return:Any idea why is
pants test
is building packaging 23.0 instead of 20.9?The text was updated successfully, but these errors were encountered: