Skip to content

Improve PluginValidationErrors #5102

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

Closed
blueyed opened this issue Apr 13, 2019 · 0 comments
Closed

Improve PluginValidationErrors #5102

blueyed opened this issue Apr 13, 2019 · 0 comments
Labels
type: enhancement new feature or API change, should be merged into features branch

Comments

@blueyed
Copy link
Contributor

blueyed commented Apr 13, 2019

PluginValidationErrors should be turned into a friendlier error message, and especially stating the reason in a more useful way.

pluggy.manager.PluginValidationError: Plugin 'xdist' could not be loaded: (pytest 4.1.1 (/tmp/tox…/Vcs/pytest-testmon/py36-pytest41-xdist/lib/python3.6/site-packages), Requirement.parse('pytest>=4.4.0'))!

This should say instead:

The plugin "xdist" could not be loaded (requires pytest>=4.4.0, but has pytest 4.1.1)

The best might be to check/handle PluginValidationError in main().

Currently it looks like this:

Traceback (most recent call last):
  File "/tmp/tox…/Vcs/pytest-testmon/py36-pytest41-xdist/lib/python3.6/site-packages/pluggy/manager.py", line 274, in load_setuptools_entrypoints
    plugin = ep.load()
  File "/tmp/tox…/Vcs/pytest-testmon/py36-pytest41-xdist/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2433, in load
    self.require(*args, **kwargs)
  File "/tmp/tox…/Vcs/pytest-testmon/py36-pytest41-xdist/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2456, in require
    items = working_set.resolve(reqs, env, installer, extras=self.extras)
  File "/tmp/tox…/Vcs/pytest-testmon/py36-pytest41-xdist/lib/python3.6/site-packages/pkg_resources/__init__.py", line 791, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (pytest 4.1.1 (/tmp/tox…/Vcs/pytest-testmon/py36-pytest41-xdist/lib/python3.6/site-packages), Requirement.parse('pytest>=4.4.0'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/tox…/Vcs/pytest-testmon/py36-pytest41-xdist/bin/py.test", line 10, in <module>
    sys.exit(main())
  File "/tmp/tox…/Vcs/pytest-testmon/py36-pytest41-xdist/lib/python3.6/site-packages/_pytest/config/__init__.py", line 61, in main
    config = _prepareconfig(args, plugins)
  File "/tmp/tox…/Vcs/pytest-testmon/py36-pytest41-xdist/lib/python3.6/site-packages/_pytest/config/__init__.py", line 196, in _prepareconfig
    pluginmanager=pluginmanager, args=args
  File "/tmp/tox…/Vcs/pytest-testmon/py36-pytest41-xdist/lib/python3.6/site-packages/pluggy/hooks.py", line 289, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/tmp/tox…/Vcs/pytest-testmon/py36-pytest41-xdist/lib/python3.6/site-packages/pluggy/manager.py", line 68, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/tmp/tox…/Vcs/pytest-testmon/py36-pytest41-xdist/lib/python3.6/site-packages/pluggy/manager.py", line 62, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "/tmp/tox…/Vcs/pytest-testmon/py36-pytest41-xdist/lib/python3.6/site-packages/pluggy/callers.py", line 203, in _multicall
    gen.send(outcome)
  File "/tmp/tox…/Vcs/pytest-testmon/py36-pytest41-xdist/lib/python3.6/site-packages/_pytest/helpconfig.py", line 93, in pytest_cmdline_parse
    config = outcome.get_result()
  File "/tmp/tox…/Vcs/pytest-testmon/py36-pytest41-xdist/lib/python3.6/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/tmp/tox…/Vcs/pytest-testmon/py36-pytest41-xdist/lib/python3.6/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/tmp/tox…/Vcs/pytest-testmon/py36-pytest41-xdist/lib/python3.6/site-packages/_pytest/config/__init__.py", line 652, in pytest_cmdline_parse
    self.parse(args)
  File "/tmp/tox…/Vcs/pytest-testmon/py36-pytest41-xdist/lib/python3.6/site-packages/_pytest/config/__init__.py", line 838, in parse
    self._preparse(args, addopts=addopts)
  File "/tmp/tox…/Vcs/pytest-testmon/py36-pytest41-xdist/lib/python3.6/site-packages/_pytest/config/__init__.py", line 784, in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "/tmp/tox…/Vcs/pytest-testmon/py36-pytest41-xdist/lib/python3.6/site-packages/pluggy/manager.py", line 280, in load_setuptools_entrypoints
    message="Plugin %r could not be loaded: %s!" % (ep.name, e),
pluggy.manager.PluginValidationError: Plugin 'xdist' could not be loaded: (pytest 4.1.1 (/tmp/tox…/Vcs/pytest-testmon/py36-pytest41-xdist/lib/python3.6/site-packages), Requirement.parse('pytest>=4.4.0'))!

Somehow related PR for inspiration: #4077.

@blueyed blueyed added the type: enhancement new feature or API change, should be merged into features branch label Apr 13, 2019
@blueyed blueyed closed this as completed Nov 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement new feature or API change, should be merged into features branch
Projects
None yet
Development

No branches or pull requests

1 participant