What happens to third‑party plugins when a pytest upgrade is only partially applied?
0 reputation · 10 Oct 2023, 14:23 UTC
0 reputation · 10 Oct 2023, 14:23 UTC
After a pytest upgrade fails mid‑install, the environment may contain a mixture of old and new pytest files while third‑party plugins remain tied to the version they were originally installed against.
The goal is to determine whether the pytest test runner can automatically reconcile these version differences or whether manual intervention is required to restore a consistent plugin‑core set.
Does pytest automatically unload older plugin versions when core modules are upgraded? Does a force‑reinstall of pytest also reinstall plugins to matching versions? What steps are required to guarantee a consistent plugin‑core version set after a failed upgrade?
31775 reputation · 10 Oct 2023, 19:35 UTC
When a pytest upgrade is only partially applied, the test runner does not automatically unload or downgrade existing third‑party plugins. Plugins stay bound to the version they were installed against and are loaded only if their declared pytest version requirement (if any) matches the current core.
If the plugin was built against an older pytest API, the newer core may have removed or changed the symbols it imports. During plugin loading pytest attempts to import the plugin; an ImportError or other exception occurs, pytest logs a warning and skips the plugin. Consequently any fixtures, hooks, or command‑line options the plugin provides are missing, which can make tests fail or behave differently.
pytest version requirement (if declared) and skips the plugin with a warning when the requirement is not satisfied.pip install -U --force-reinstall pytest) does not automatically reinstall plugins; each plugin must be upgraded separately to match the new pytest version.pytest --version.pytest --collect-only -v. Look for warnings like ‘skipping plugin … because it requires a different pytest version’.pip install -U pytest‑myplugin (repeat for each plugin).pip install -U --force-reinstall pytest to ensure a clean core, then repeat step 4.pytest --collect-only -v again and verifying that all expected plugins appear without warnings.If you still see loading failures after these steps, please share the exact error message or warning output so the diagnosis can be refined.
Use comments to ask for clarification. Post a solution as an answer.
31,775 reputation · 10 Oct 2023, 17:46 UTC
When a pytest upgrade is interrupted, the environment often enters an inconsistent state where the core runner and its third-party plugins are out of sync. It is important to note that pytest does not have an internal reconciliation mechanism; it attempts to load every plugin discovered via entry points regardless of version mismatches.
If a plugin was installed for an older version and the core has been partially upgraded, you will likely encounter an ImportError or AttributeError during the collection phase. While pytest may skip the incompatible plugin with a warning, this can lead to silent test failures where critical fixtures or hooks provided by that plugin are simply missing.
To ensure a consistent environment, a simple force-reinstall of pytest is insufficient because pip does not recursively trigger updates for dependent plugins. You must manually verify the loaded plugin set using pytest --collect-only -v and upgrade each plugin individually to match the new core version.