Skip to content
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

Fix compatibility with pytest master #554

Merged
merged 2 commits into from Jul 9, 2020

Conversation

nicoddemus
Copy link
Member

@nicoddemus nicoddemus commented Jul 8, 2020

  • Fix the autouse fixture which diverts atexit.register calls to support the correct signature.
  • Support the new pytest_warning_recorded hook.

Fix the autouse fixture which diverts atexit.register calls to support the correct signature.
@nicoddemus nicoddemus merged commit b8e1e63 into pytest-dev:master Jul 9, 2020
@nicoddemus nicoddemus deleted the fix-compat-pytest-master branch July 9, 2020 19:49
nicoddemus added a commit to nicoddemus/pytest-xdist that referenced this pull request Jul 9, 2020
@hroncok
Copy link
Member

hroncok commented Jul 20, 2020

Hello @nicoddemus. I have a question about this code. When I test hypothesis 5.15.1 with this version of pytest-xdist and pytest 6.0.0rc1 I get:

+ pytest-3 -v -n auto -k 'not test_healthcheck_traceback_is_hidden'
============================= test session starts ==============================
platform linux -- Python 3.9.0b4, pytest-6.0.0rc1, py-1.9.0, pluggy-0.13.1 -- /usr/bin/python3
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/tmp/tmpghr1kmm6/examples')
rootdir: /builddir/build/BUILD/hypothesis-hypothesis-python-5.15.1, configfile: pytest.ini
plugins: hypothesis-5.15.1, xdist-1.33.0, forked-1.2.0
gw0 I / gw1 I
[gw0] linux Python 3.9.0 cwd: /builddir/build/BUILD/hypothesis-hypothesis-python-5.15.1/hypothesis-python
[gw1] linux Python 3.9.0 cwd: /builddir/build/BUILD/hypothesis-hypothesis-python-5.15.1/hypothesis-python
[gw0] node down: Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/execnet/gateway_base.py", line 1084, in executetask
    do_exec(co, loc)  # noqa
  File "/usr/lib/python3.9/site-packages/xdist/remote.py", line 272, in <module>
    interactor = WorkerInteractor(config, channel)
  File "/usr/lib/python3.9/site-packages/xdist/remote.py", line 30, in __init__
    config.pluginmanager.register(self)
  File "/usr/lib/python3.9/site-packages/_pytest/config/__init__.py", line 424, in register
    ret = super().register(plugin, name)  # type: Optional[str]
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 126, in register
    self._verify_hook(hook, hookimpl)
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 248, in _verify_hook
    _warn_for_function(hook.spec.warn_on_impl, hookimpl.function)
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 15, in _warn_for_function
    warnings.warn_explicit(
pytest.PytestDeprecationWarning: The pytest_warning_captured is deprecated and will be removed in a future release.
Please use pytest_warning_recorded instead.


replacing crashed worker gw0
[gw2] linux Python 3.9.0 cwd: /builddir/build/BUILD/hypothesis-hypothesis-python-5.15.1/hypothesis-python
[gw1] node down: Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/execnet/gateway_base.py", line 1084, in executetask
    do_exec(co, loc)  # noqa
  File "/usr/lib/python3.9/site-packages/xdist/remote.py", line 272, in <module>
    interactor = WorkerInteractor(config, channel)
  File "/usr/lib/python3.9/site-packages/xdist/remote.py", line 30, in __init__
    config.pluginmanager.register(self)
  File "/usr/lib/python3.9/site-packages/_pytest/config/__init__.py", line 424, in register
    ret = super().register(plugin, name)  # type: Optional[str]
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 126, in register
    self._verify_hook(hook, hookimpl)
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 248, in _verify_hook
    _warn_for_function(hook.spec.warn_on_impl, hookimpl.function)
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 15, in _warn_for_function
    warnings.warn_explicit(
pytest.PytestDeprecationWarning: The pytest_warning_captured is deprecated and will be removed in a future release.
Please use pytest_warning_recorded instead.


replacing crashed worker gw1
[gw3] linux Python 3.9.0 cwd: /builddir/build/BUILD/hypothesis-hypothesis-python-5.15.1/hypothesis-python
[gw2] node down: Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/execnet/gateway_base.py", line 1084, in executetask
    do_exec(co, loc)  # noqa
  File "/usr/lib/python3.9/site-packages/xdist/remote.py", line 272, in <module>
    interactor = WorkerInteractor(config, channel)
  File "/usr/lib/python3.9/site-packages/xdist/remote.py", line 30, in __init__
    config.pluginmanager.register(self)
  File "/usr/lib/python3.9/site-packages/_pytest/config/__init__.py", line 424, in register
    ret = super().register(plugin, name)  # type: Optional[str]
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 126, in register
    self._verify_hook(hook, hookimpl)
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 248, in _verify_hook
    _warn_for_function(hook.spec.warn_on_impl, hookimpl.function)
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 15, in _warn_for_function
    warnings.warn_explicit(
pytest.PytestDeprecationWarning: The pytest_warning_captured is deprecated and will be removed in a future release.
Please use pytest_warning_recorded instead.


replacing crashed worker gw2
[gw4] linux Python 3.9.0 cwd: /builddir/build/BUILD/hypothesis-hypothesis-python-5.15.1/hypothesis-python
[gw3] node down: Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/execnet/gateway_base.py", line 1084, in executetask
    do_exec(co, loc)  # noqa
  File "/usr/lib/python3.9/site-packages/xdist/remote.py", line 272, in <module>
    interactor = WorkerInteractor(config, channel)
  File "/usr/lib/python3.9/site-packages/xdist/remote.py", line 30, in __init__
    config.pluginmanager.register(self)
  File "/usr/lib/python3.9/site-packages/_pytest/config/__init__.py", line 424, in register
    ret = super().register(plugin, name)  # type: Optional[str]
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 126, in register
    self._verify_hook(hook, hookimpl)
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 248, in _verify_hook
    _warn_for_function(hook.spec.warn_on_impl, hookimpl.function)
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 15, in _warn_for_function
    warnings.warn_explicit(
pytest.PytestDeprecationWarning: The pytest_warning_captured is deprecated and will be removed in a future release.
Please use pytest_warning_recorded instead.


replacing crashed worker gw3
[gw5] linux Python 3.9.0 cwd: /builddir/build/BUILD/hypothesis-hypothesis-python-5.15.1/hypothesis-python
[gw4] node down: Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/execnet/gateway_base.py", line 1084, in executetask
    do_exec(co, loc)  # noqa
  File "/usr/lib/python3.9/site-packages/xdist/remote.py", line 272, in <module>
    interactor = WorkerInteractor(config, channel)
  File "/usr/lib/python3.9/site-packages/xdist/remote.py", line 30, in __init__
    config.pluginmanager.register(self)
  File "/usr/lib/python3.9/site-packages/_pytest/config/__init__.py", line 424, in register
    ret = super().register(plugin, name)  # type: Optional[str]
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 126, in register
    self._verify_hook(hook, hookimpl)
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 248, in _verify_hook
    _warn_for_function(hook.spec.warn_on_impl, hookimpl.function)
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 15, in _warn_for_function
    warnings.warn_explicit(
pytest.PytestDeprecationWarning: The pytest_warning_captured is deprecated and will be removed in a future release.
Please use pytest_warning_recorded instead.


replacing crashed worker gw4
[gw6] linux Python 3.9.0 cwd: /builddir/build/BUILD/hypothesis-hypothesis-python-5.15.1/hypothesis-python
[gw5] node down: Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/execnet/gateway_base.py", line 1084, in executetask
    do_exec(co, loc)  # noqa
  File "/usr/lib/python3.9/site-packages/xdist/remote.py", line 272, in <module>
    interactor = WorkerInteractor(config, channel)
  File "/usr/lib/python3.9/site-packages/xdist/remote.py", line 30, in __init__
    config.pluginmanager.register(self)
  File "/usr/lib/python3.9/site-packages/_pytest/config/__init__.py", line 424, in register
    ret = super().register(plugin, name)  # type: Optional[str]
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 126, in register
    self._verify_hook(hook, hookimpl)
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 248, in _verify_hook
    _warn_for_function(hook.spec.warn_on_impl, hookimpl.function)
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 15, in _warn_for_function
    warnings.warn_explicit(
pytest.PytestDeprecationWarning: The pytest_warning_captured is deprecated and will be removed in a future release.
Please use pytest_warning_recorded instead.


replacing crashed worker gw5
[gw7] linux Python 3.9.0 cwd: /builddir/build/BUILD/hypothesis-hypothesis-python-5.15.1/hypothesis-python
[gw6] node down: Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/execnet/gateway_base.py", line 1084, in executetask
    do_exec(co, loc)  # noqa
  File "/usr/lib/python3.9/site-packages/xdist/remote.py", line 272, in <module>
    interactor = WorkerInteractor(config, channel)
  File "/usr/lib/python3.9/site-packages/xdist/remote.py", line 30, in __init__
    config.pluginmanager.register(self)
  File "/usr/lib/python3.9/site-packages/_pytest/config/__init__.py", line 424, in register
    ret = super().register(plugin, name)  # type: Optional[str]
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 126, in register
    self._verify_hook(hook, hookimpl)
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 248, in _verify_hook
    _warn_for_function(hook.spec.warn_on_impl, hookimpl.function)
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 15, in _warn_for_function
    warnings.warn_explicit(
pytest.PytestDeprecationWarning: The pytest_warning_captured is deprecated and will be removed in a future release.
Please use pytest_warning_recorded instead.


replacing crashed worker gw6
[gw8] linux Python 3.9.0 cwd: /builddir/build/BUILD/hypothesis-hypothesis-python-5.15.1/hypothesis-python
[gw7] node down: Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/execnet/gateway_base.py", line 1084, in executetask
    do_exec(co, loc)  # noqa
  File "/usr/lib/python3.9/site-packages/xdist/remote.py", line 272, in <module>
    interactor = WorkerInteractor(config, channel)
  File "/usr/lib/python3.9/site-packages/xdist/remote.py", line 30, in __init__
    config.pluginmanager.register(self)
  File "/usr/lib/python3.9/site-packages/_pytest/config/__init__.py", line 424, in register
    ret = super().register(plugin, name)  # type: Optional[str]
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 126, in register
    self._verify_hook(hook, hookimpl)
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 248, in _verify_hook
    _warn_for_function(hook.spec.warn_on_impl, hookimpl.function)
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 15, in _warn_for_function
    warnings.warn_explicit(
pytest.PytestDeprecationWarning: The pytest_warning_captured is deprecated and will be removed in a future release.
Please use pytest_warning_recorded instead.


replacing crashed worker gw7
[gw9] linux Python 3.9.0 cwd: /builddir/build/BUILD/hypothesis-hypothesis-python-5.15.1/hypothesis-python
[gw8] node down: Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/execnet/gateway_base.py", line 1084, in executetask
    do_exec(co, loc)  # noqa
  File "/usr/lib/python3.9/site-packages/xdist/remote.py", line 272, in <module>
    interactor = WorkerInteractor(config, channel)
  File "/usr/lib/python3.9/site-packages/xdist/remote.py", line 30, in __init__
    config.pluginmanager.register(self)
  File "/usr/lib/python3.9/site-packages/_pytest/config/__init__.py", line 424, in register
    ret = super().register(plugin, name)  # type: Optional[str]
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 126, in register
    self._verify_hook(hook, hookimpl)
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 248, in _verify_hook
    _warn_for_function(hook.spec.warn_on_impl, hookimpl.function)
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 15, in _warn_for_function
    warnings.warn_explicit(
pytest.PytestDeprecationWarning: The pytest_warning_captured is deprecated and will be removed in a future release.
Please use pytest_warning_recorded instead.


maximum crashed workers reached: 8
[gw9] node down: Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/execnet/gateway_base.py", line 1084, in executetask
    do_exec(co, loc)  # noqa
  File "/usr/lib/python3.9/site-packages/xdist/remote.py", line 272, in <module>
    interactor = WorkerInteractor(config, channel)
  File "/usr/lib/python3.9/site-packages/xdist/remote.py", line 30, in __init__
    config.pluginmanager.register(self)
  File "/usr/lib/python3.9/site-packages/_pytest/config/__init__.py", line 424, in register
    ret = super().register(plugin, name)  # type: Optional[str]
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 126, in register
    self._verify_hook(hook, hookimpl)
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 248, in _verify_hook
    _warn_for_function(hook.spec.warn_on_impl, hookimpl.function)
  File "/usr/lib/python3.9/site-packages/pluggy/manager.py", line 15, in _warn_for_function
    warnings.warn_explicit(
pytest.PytestDeprecationWarning: The pytest_warning_captured is deprecated and will be removed in a future release.
Please use pytest_warning_recorded instead.


maximum crashed workers reached: 8

================== xdist: maximum crashed workers reached: 8 ===================

But the only place where pytest_warning_captured is even mentioned is in pytest and pytest-xdist code :/

@The-Compiler
Copy link
Member

I don't know much about xdist, but from what I can see, this PR only implements the new pytest_warning_recorded hook, it doesn't avoid implementing the (now deprecated) pytest_warning_captured hook.

Perhaps something similar to c5f65b3 is needed here as well? I'm sure @nicoddemus can say more though, I'm just guessing.

@Zac-HD
Copy link
Member

Zac-HD commented Jul 22, 2020

This is... bad, I quite like using Hypothesis with pytest-xdist and I wouldn't like to break it for our users either.

Looking at the traceback - I have something very similar locally - I think the problem might be in either execnet or pluggy... and pytest-dev/pluggy#178 might be relevant?

@The-Compiler
Copy link
Member

I don't think this is related to hypothesis per se - I assume anything using xdist will get the warning, but hypothesis configures its testsuite to turn that warning into an error?

@hroncok
Copy link
Member

hroncok commented Jul 22, 2020

Indeed.

@Zac-HD
Copy link
Member

Zac-HD commented Jul 23, 2020

Hypothesis does indeed treat all warnings as errors.

A quick attempt to reproduce this on a small example with pytest -Werror -n 2 test.py failed though, as did python -Werror -m pytest .... So it might be something slightly more complex about our test suite?

@nicoddemus
Copy link
Member Author

Hey folks,

Yeah, the problem is that the worker always triggers the deprecated hook... I will open a PR shortly where it will trigger one hook or the other, but not both, based on availability. 👍

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

Successfully merging this pull request may close these issues.

None yet

4 participants