Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

unknown hook 'pytest_xdist_node_collection_finished' in plugin mozlog #1

Closed
maxious opened this issue May 23, 2017 · 6 comments
Closed

Comments

@maxious
Copy link

maxious commented May 23, 2017

A new version of pytest has been released (3.1.0) with some extra hook checking pytest-dev/pytest#1821

Rolling back to 3.0.7 resolves this for now.

> py.test
============================= test session starts ==============================
platform linux2 -- Python 2.7.12, pytest-3.1.0, py-1.4.33, pluggy-0.4.0
rootdir: /home/ubuntu/dto-digitalmarketplace-buyer-frontend, inifile: setup.cfg
plugins: cov-2.5.1, bdd-2.18.2, mozlog-3.4
collecting 422 itemsINTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/main.py", line 105, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/main.py", line 140, in _main
INTERNALERROR>     config.hook.pytest_collection(session=session)
INTERNALERROR>   File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/main.py", line 150, in pytest_collection
INTERNALERROR>     return session.perform_collect()
INTERNALERROR>   File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/main.py", line 605, in perform_collect
INTERNALERROR>     self.config.pluginmanager.check_pending()
INTERNALERROR>   File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 498, in check_pending
INTERNALERROR>     (name, hookimpl.plugin))
INTERNALERROR> PluginValidationError: unknown hook 'pytest_xdist_node_collection_finished' in plugin <mozlog.pytest_mozlog.plugin.MozLog object at 0x7f7a9056ead0>
@edmorley
Copy link

edmorley commented May 26, 2017

There has been a follow-up fix to the new feature which stops it reporting errors in some cases which it shouldn't (pytest-dev/pytest#2292), however I think this might actually not help here, since I think pytest-mozlog isn't marking the xdist plugin as optional, like so:
https://docs.pytest.org/en/latest/writing_plugins.html#optionally-using-hooks-from-3rd-party-plugins

@edmorley
Copy link

edmorley commented Jun 5, 2017

however I think this might actually not help here, since I think pytest-mozlog isn't marking the xdist plugin as optional

Yeah the followup in pytest didn't help, the issue still occurs in pytest 3.1.1.

@davehunt
Copy link
Owner

Sorry for the confusion, this repo was for an early prototype of a pytest-mozlog plugin. The actual source code is now to be found in mozlog itself: https://dxr.mozilla.org/mozilla-central/source/testing/mozbase/mozlog/mozlog/pytest_mozlog

I think all that's needed here is to mark the hooks as optional, such as:

@pytest.mark.optionalhook
def pytest_xdist_node_collection_finished(self, node, ids):
    '''Called after each pytest-xdist node collection is completed'''
    self._log_suite_start(ids)

Alternatively, install or add pytest-xdist as a dependency, but that not ideal as the pytest-mozlog plugin should work with or without pytest-xdist.

@davehunt
Copy link
Owner

I'll add a note to the README of this repo redirecting to the canonical source.

@davehunt
Copy link
Owner

Also, if you're not using pytest-mozlog and want to disable it, see https://docs.pytest.org/en/latest/usage.html?highlight=disable%20plugin#disabling-plugins for details, but something like pytest -p no:mozlog should work.

@davehunt
Copy link
Owner

This has now been raised as bug 1375145.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants