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

TypeError with Python 3.6.8/pytest 5.1.3 on Ubuntu 18.04.3 LTS #40

Closed synergiator closed 4 years ago

synergiator commented 4 years ago

Hi, all,

I am very happy to discover this wonderful plugin!

Call configuration: --workers auto

Unfortunately, soon enough I have got the following exception:

Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner self.run() File "/home/user/.virtualenvs/apache-cs-extensions/lib/python3.6/site-packages/pytest_parallel/init.py", line 81, in run run_test(self.session, item, None) File "/home/user/.virtualenvs/apache-cs-extensions/lib/python3.6/site-packages/pytest_parallel/init.py", line 51, in run_test item.ihook.pytest_runtest_protocol(item=item, nextitem=nextitem) File "/home/user/.virtualenvs/apache-cs-extensions/lib/python3.6/site-packages/pluggy/hooks.py", line 286, in call return self._hookexec(self, self.get_hookimpls(), kwargs) File "/home/user/.virtualenvs/apache-cs-extensions/lib/python3.6/site-packages/pluggy/manager.py", line 92, in _hookexec return self._inner_hookexec(hook, methods, kwargs) File "/home/user/.virtualenvs/apache-cs-extensions/lib/python3.6/site-packages/pluggy/manager.py", line 86, in firstresult=hook.spec.opts.get("firstresult") if hook.spec else False, File "/home/user/.virtualenvs/apache-cs-extensions/lib/python3.6/site-packages/pluggy/callers.py", line 208, in _multicall return outcome.get_result() File "/home/user/.virtualenvs/apache-cs-extensions/lib/python3.6/site-packages/pluggy/callers.py", line 80, in get_result raise ex[1].with_traceback(ex[2]) File "/home/user/.virtualenvs/apache-cs-extensions/lib/python3.6/site-packages/pluggy/callers.py", line 187, in _multicall res = hook_impl.function(args) File "/home/user/.virtualenvs/apache-cs-extensions/lib/python3.6/site-packages/_pytest/runner.py", line 72, in pytest_runtest_protocol runtestprotocol(item, nextitem=nextitem) File "/home/user/.virtualenvs/apache-cs-extensions/lib/python3.6/site-packages/_pytest/runner.py", line 87, in runtestprotocol reports.append(call_and_report(item, "call", log)) File "/home/user/.virtualenvs/apache-cs-extensions/lib/python3.6/site-packages/_pytest/runner.py", line 171, in call_and_report hook.pytest_runtest_logreport(report=report) File "/home/user/.virtualenvs/apache-cs-extensions/lib/python3.6/site-packages/pluggy/hooks.py", line 286, in call return self._hookexec(self, self.get_hookimpls(), kwargs) File "/home/user/.virtualenvs/apache-cs-extensions/lib/python3.6/site-packages/pluggy/manager.py", line 92, in _hookexec return self._inner_hookexec(hook, methods, kwargs) File "/home/user/.virtualenvs/apache-cs-extensions/lib/python3.6/site-packages/pluggy/manager.py", line 86, in firstresult=hook.spec.opts.get("firstresult") if hook.spec else False, File "/home/user/.virtualenvs/apache-cs-extensions/lib/python3.6/site-packages/pluggy/callers.py", line 208, in _multicall return outcome.get_result() File "/home/user/.virtualenvs/apache-cs-extensions/lib/python3.6/site-packages/pluggy/callers.py", line 80, in get_result raise ex[1].with_traceback(ex[2]) File "/home/user/.virtualenvs/apache-cs-extensions/lib/python3.6/site-packages/pluggy/callers.py", line 187, in _multicall res = hook_impl.function(args) File "/home/user/.virtualenvs/apache-cs-extensions/lib/python3.6/site-packages/_pytest/main.py", line 412, in pytest_runtest_logreport if maxfail and self.testsfTypeError: '>=' not supported between instances of 'SafeNumber' and 'int'ailed >= maxfail: TypeError: '>=' not supported between instances of 'SafeNumber' and 'int'#

It seems that pytest-parallel defines a class SafeNumber which is then causes a pytest exception in the following method:


@hookimpl(tryfirst=True)
    def pytest_runtest_logreport(self, report):
        if report.failed and not hasattr(report, "wasxfail"):
            self.testsfailed += 1
            maxfail = self.config.getvalue("maxfail")
            if maxfail and self.testsfailed >= maxfail:
                self.shouldfail = "stopping after %d failures" % (self.testsfailed)

What I do not understand, how comes that maxfail which should be a config value becomes an instance of SafeNumber.

blueyed commented 4 years ago

What I do not understand, how comes that maxfail which should be a config value becomes an instance of SafeNumber.

That's done for thread safety.

blueyed commented 4 years ago

Duplicate of https://github.com/browsertron/pytest-parallel/issues/37.

kevlened commented 4 years ago

Resolved in 0.0.10 (Thanks @blueyed!)