kevlened / pytest-parallel

A pytest plugin for parallel and concurrent testing
https://github.com/browsertron/pytest-parallel/issues/104#issuecomment-1293941066
MIT License
313 stars 60 forks source link

AttributeError: 'NoneType' object has no attribute '_registry' with pytest 5.3.0 #46

Closed JuleBert closed 4 years ago

JuleBert commented 4 years ago

Hi there,

I run pytest with pytest-parallel (v 0.0.9) in a Gitlab CI-Pipeline. Without changing my code the pipeline jobs stopped working. The only thing that change was the pytest version from 5.2.4 to 5.3.0.

Also the pipeline job doesn't seem to stop. It's stuck in the status running until I cancel it.

The failed command is: - python setup.py install && pytest --workers 4 where setup.py install is our project specific setup script.

The hopefully relevant output:

============================= test session starts ==============================
platform linux -- Python 3.7.5, pytest-5.3.0, py-1.8.0, pluggy-0.13.0
rootdir: /builds/fsd/odx-ninja
plugins: parallel-0.0.9
collected 70 items
pytest-parallel: 4 workers (processes), 1 test per worker (thread)
....Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.7/site-packages/pytest_parallel/__init__.py", line 81, in run
    run_test(self.session, item, None)
  File "/usr/local/lib/python3.7/site-packages/pytest_parallel/__init__.py", line 51, in run_test
    item.ihook.pytest_runtest_protocol(item=item, nextitem=nextitem)
  File "/usr/local/lib/python3.7/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/usr/local/lib/python3.7/site-packages/pluggy/manager.py", line 92, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/usr/local/lib/python3.7/site-packages/pluggy/manager.py", line 86, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "/usr/local/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
    return outcome.get_result()
  File "/usr/local/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/usr/local/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/usr/local/lib/python3.7/site-packages/_pytest/runner.py", line 82, in pytest_runtest_protocol
    item.ihook.pytest_runtest_logfinish(nodeid=item.nodeid, location=item.location)
  File "/usr/local/lib/python3.7/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/usr/local/lib/python3.7/site-packages/pluggy/manager.py", line 92, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/usr/local/lib/python3.7/site-packages/pluggy/manager.py", line 86, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "/usr/local/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
    return outcome.get_result()
  File "/usr/local/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/usr/local/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/usr/local/lib/python3.7/site-packages/_pytest/terminal.py", line 468, in pytest_runtest_logfinish
    main_color, _ = _get_main_color(self.stats)
  File "/usr/local/lib/python3.7/site-packages/_pytest/terminal.py", line 1102, in _get_main_color
    for found_type in stats:
  File "<string>", line 2, in __iter__
  File "/usr/local/lib/python3.7/multiprocessing/managers.py", line 825, in _callmethod
    proxytype = self._manager._registry[token.typeid][-1]
AttributeError: 'NoneType' object has no attribute '_registry'

When the --workers 4 was removed the CI pipeline didn't fail.

To avoid this we now fixed the pytest version to 5.2.4.

I also created an issue at pytest: https://github.com/pytest-dev/pytest/issues/6254

I hope I could help.

Best regards

blueyed commented 4 years ago

See https://github.com/browsertron/pytest-parallel/issues/36#issuecomment-554196577.

blueyed commented 4 years ago

As a workaround pytest -o console_output_style=classic should also work (#50).

blueyed commented 4 years ago

This is fixed.

@kevlened There are quite a few more fixed / duplicate issues, would be good if you could go through them. Happy to help there also, but would require to invite me to the repo.

kevlened commented 4 years ago

Thanks @blueyed! I'll go through them this afternoon.

JuleBert commented 4 years ago

Hi there, with pytest-parallel version 0.0.10 it now works.

Thanks a lot!