pytest-dev / pytest-xdist

pytest plugin for distributed testing and loop-on-failures testing modes.
https://pytest-xdist.readthedocs.io
MIT License
1.48k stars 232 forks source link

execnet.gateway_base.DumpError: can't serialize <class '_pytest.warning_types.RemovedInPytest4Warning'> #364

Open blueyed opened 6 years ago

blueyed commented 6 years ago

Stumbled upon this with borg's tests: https://travis-ci.org/borgbackup/borg/jobs/439508853#L2123

  File "/Users/travis/build/borgbackup/borg/.tox/py34/lib/python3.4/site-packages/execnet/gateway_base.py", line 1383, in _save
    dispatch = self._dispatch[tp]
KeyError: <class '_pytest.warning_types.RemovedInPytest4Warning'>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/Users/travis/build/borgbackup/borg/.tox/py34/lib/python3.4/site-packages/execnet/gateway_base.py", line 1072, in executetask
    do_exec(co, loc)  # noqa
  File "<string>", line 1, in do_exec
  File "<remote exec>", line 261, in <module>
  File "<remote exec>", line 25, in __init__
  File "/Users/travis/build/borgbackup/borg/.tox/py34/lib/python3.4/site-packages/_pytest/config/__init__.py", line 303, in register
    ret = super(PytestPluginManager, self).register(plugin, name)
  File "/Users/travis/build/borgbackup/borg/.tox/py34/lib/python3.4/site-packages/pluggy/manager.py", line 101, in register
    hook._maybe_apply_history(hookimpl)
  File "/Users/travis/build/borgbackup/borg/.tox/py34/lib/python3.4/site-packages/pluggy/hooks.py", line 331, in _maybe_apply_history
    res = self._hookexec(self, [method], kwargs)
  File "/Users/travis/build/borgbackup/borg/.tox/py34/lib/python3.4/site-packages/pluggy/manager.py", line 67, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/Users/travis/build/borgbackup/borg/.tox/py34/lib/python3.4/site-packages/pluggy/manager.py", line 61, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False
  File "/Users/travis/build/borgbackup/borg/.tox/py34/lib/python3.4/site-packages/pluggy/callers.py", line 208, in _multicall
    return outcome.get_result()
  File "/Users/travis/build/borgbackup/borg/.tox/py34/lib/python3.4/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/Users/travis/build/borgbackup/borg/.tox/py34/lib/python3.4/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "<remote exec>", line 135, in pytest_warning_captured
  File "<remote exec>", line 29, in sendevent
  File "/Users/travis/build/borgbackup/borg/.tox/py34/lib/python3.4/site-packages/execnet/gateway_base.py", line 717, in send
    self.gateway._send(Message.CHANNEL_DATA, self.id, dumps_internal(item))
  File "/Users/travis/build/borgbackup/borg/.tox/py34/lib/python3.4/site-packages/execnet/gateway_base.py", line 1354, in dumps_internal
    return _Serializer().save(obj)
  File "/Users/travis/build/borgbackup/borg/.tox/py34/lib/python3.4/site-packages/execnet/gateway_base.py", line 1372, in save
    self._save(obj)
  File "/Users/travis/build/borgbackup/borg/.tox/py34/lib/python3.4/site-packages/execnet/gateway_base.py", line 1390, in _save
    dispatch(self, obj)
  File "/Users/travis/build/borgbackup/borg/.tox/py34/lib/python3.4/site-packages/execnet/gateway_base.py", line 1475, in save_tuple
    self._save(item)
  File "/Users/travis/build/borgbackup/borg/.tox/py34/lib/python3.4/site-packages/execnet/gateway_base.py", line 1390, in _save
    dispatch(self, obj)
  File "/Users/travis/build/borgbackup/borg/.tox/py34/lib/python3.4/site-packages/execnet/gateway_base.py", line 1471, in save_dict
    self._write_setitem(key, value)
  File "/Users/travis/build/borgbackup/borg/.tox/py34/lib/python3.4/site-packages/execnet/gateway_base.py", line 1465, in _write_setitem
    self._save(value)
  File "/Users/travis/build/borgbackup/borg/.tox/py34/lib/python3.4/site-packages/execnet/gateway_base.py", line 1390, in _save
    dispatch(self, obj)
  File "/Users/travis/build/borgbackup/borg/.tox/py34/lib/python3.4/site-packages/execnet/gateway_base.py", line 1471, in save_dict
    self._write_setitem(key, value)
  File "/Users/travis/build/borgbackup/borg/.tox/py34/lib/python3.4/site-packages/execnet/gateway_base.py", line 1465, in _write_setitem
    self._save(value)
  File "/Users/travis/build/borgbackup/borg/.tox/py34/lib/python3.4/site-packages/execnet/gateway_base.py", line 1390, in _save
    dispatch(self, obj)
  File "/Users/travis/build/borgbackup/borg/.tox/py34/lib/python3.4/site-packages/execnet/gateway_base.py", line 1475, in save_tuple
    self._save(item)
  File "/Users/travis/build/borgbackup/borg/.tox/py34/lib/python3.4/site-packages/execnet/gateway_base.py", line 1388, in _save
    raise DumpError("can't serialize %s" % (tp,))
execnet.gateway_base.DumpError: can't serialize <class '_pytest.warning_types.RemovedInPytest4Warning'>
Replacing crashed worker gw0

Python 3.4.5, pytest-3.9.3, py-1.7.0, pluggy-0.8.0

Issue: https://github.com/borgbackup/borg/issues/4123

RonnyPfannschmidt commented 6 years ago

cc @nicoddemus

paul-ko commented 5 years ago

Hi, I've just started experiencing this error. Is there a workaround or does it indicate an obvious issue that needs to be fixed within my own code? I've been digging into the linked ticket and the tickets it links to, but haven't been any to identify anything useful (possibly I'm overlooking something). Thanks!

Edit: I came up with a workaround that is working so far, having the pytest arg take a string and later passing the argument to a function to create an object, instead of just specifying that function as the argument's type in pytest_addoption. Feel free to disregard my comment, although if you have any information to share (or would like additional information from me) I'd certainly be interested to hear it. Thanks again.