使用pytest-xdist,按文件并发执行,有用例脚本导致整个(xdist)执行中止

该报错的脚本用例所在的文件,没有创建测试类,直接创建的测试方法

pytest的执行命令:

pytest -v ./ -n=4 --dist=loadfile --ignore=test_base_cases --ui=f --grid=f --host=${host} --alluredir=${WORKSPACE}/report/allure-results

报错信息如下:
test_case/smart_school_sys/教务管理/评价汇总/课程评估/test_course_evaluation.py::TestAppCurriculumEvaluation::test_add_evaluation
INTERNALERROR> def worker_internal_error(self, node, formatted_error):
INTERNALERROR> “”"
INTERNALERROR> pytest_internalerror() was called on the worker.
INTERNALERROR>
INTERNALERROR> pytest_internalerror() arguments are an excinfo and an excrepr, which can’t
INTERNALERROR> be serialized, so we go with a poor man’s solution of raising an exception
INTERNALERROR> here ourselves using the formatted message.
INTERNALERROR> “”"
INTERNALERROR> self._active_nodes.remove(node)
INTERNALERROR> try:
INTERNALERROR> > assert False, formatted_error
INTERNALERROR> E AssertionError: Traceback (most recent call last):
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/_pytest/main.py”, line 269, in wrap_session
INTERNALERROR> E session.exitstatus = doit(config, session) or 0
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/_pytest/main.py”, line 323, in _main
INTERNALERROR> E config.hook.pytest_runtestloop(session=session)
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/pluggy/hooks.py”, line 286, in call
INTERNALERROR> E return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/pluggy/manager.py”, line 93, in _hookexec
INTERNALERROR> E return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/pluggy/manager.py”, line 84, in
INTERNALERROR> E self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/pluggy/callers.py”, line 208, in _multicall
INTERNALERROR> E return outcome.get_result()
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/pluggy/callers.py”, line 80, in get_result
INTERNALERROR> E raise ex[1].with_traceback(ex[2])
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/pluggy/callers.py”, line 187, in _multicall
INTERNALERROR> E res = hook_impl.function(*args)
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/xdist/remote.py”, line 72, in pytest_runtestloop
INTERNALERROR> E self.run_one_test(torun)
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/xdist/remote.py”, line 89, in run_one_test
INTERNALERROR> E self.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/pluggy/hooks.py”, line 286, in call
INTERNALERROR> E return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/pluggy/manager.py”, line 93, in _hookexec
INTERNALERROR> E return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/pluggy/manager.py”, line 84, in
INTERNALERROR> E self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/pluggy/callers.py”, line 208, in _multicall
INTERNALERROR> E return outcome.get_result()
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/pluggy/callers.py”, line 80, in get_result
INTERNALERROR> E raise ex[1].with_traceback(ex[2])
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/pluggy/callers.py”, line 187, in _multicall
INTERNALERROR> E res = hook_impl.function(*args)
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/_pytest/runner.py”, line 109, in pytest_runtest_protocol
INTERNALERROR> E runtestprotocol(item, nextitem=nextitem)
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/_pytest/runner.py”, line 126, in runtestprotocol
INTERNALERROR> E reports.append(call_and_report(item, “call”, log))
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/_pytest/runner.py”, line 217, in call_and_report
INTERNALERROR> E report: TestReport = hook.pytest_runtest_makereport(item=item, call=call)
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/pluggy/hooks.py”, line 286, in call
INTERNALERROR> E return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/pluggy/manager.py”, line 93, in _hookexec
INTERNALERROR> E return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/pluggy/manager.py”, line 84, in
INTERNALERROR> E self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/pluggy/callers.py”, line 203, in _multicall
INTERNALERROR> E gen.send(outcome)
INTERNALERROR> E File “/var/lib/jenkins/workspace/djw_mysql/conftest.py”, line 198, in pytest_runtest_makereport
INTERNALERROR> E allure.attach(body=fun_driver.get_screenshot_as_png(), name=“用例失败截图”,
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py”, line 1064, in get_screenshot_as_png
INTERNALERROR> E return base64.b64decode(self.get_screenshot_as_base64().encode(‘ascii’))
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py”, line 1074, in get_screenshot_as_base64
INTERNALERROR> E return self.execute(Command.SCREENSHOT)[‘value’]
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py”, line 321, in execute
INTERNALERROR> E self.error_handler.check_response(response)
INTERNALERROR> E File “/usr/local/python/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py”, line 242, in check_response
INTERNALERROR> E raise exception_class(message, screen, stacktrace)
INTERNALERROR> E selenium.common.exceptions.TimeoutException: Message: timeout: Timed out receiving message from renderer: 300.000
INTERNALERROR> E (Session info: headless chrome=91.0.4472.114)
INTERNALERROR> E assert False
INTERNALERROR>
INTERNALERROR> /usr/local/python/lib/python3.8/site-packages/xdist/dsession.py:187: AssertionError
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File “/usr/local/python/lib/python3.8/site-packages/_pytest/main.py”, line 269, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File “/usr/local/python/lib/python3.8/site-packages/_pytest/main.py”, line 323, in _main
INTERNALERROR> config.hook.pytest_runtestloop(session=session)
INTERNALERROR> File “/usr/local/python/lib/python3.8/site-packages/pluggy/hooks.py”, line 286, in call
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File “/usr/local/python/lib/python3.8/site-packages/pluggy/manager.py”, line 93, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File “/usr/local/python/lib/python3.8/site-packages/pluggy/manager.py”, line 84, in
INTERNALERROR> self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR> File “/usr/local/python/lib/python3.8/site-packages/pluggy/callers.py”, line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File “/usr/local/python/lib/python3.8/site-packages/pluggy/callers.py”, line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File “/usr/local/python/lib/python3.8/site-packages/pluggy/callers.py”, line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File “/usr/local/python/lib/python3.8/site-packages/xdist/dsession.py”, line 112, in pytest_runtestloop
INTERNALERROR> self.loop_once()
INTERNALERROR> File “/usr/local/python/lib/python3.8/site-packages/xdist/dsession.py”, line 135, in loop_once
INTERNALERROR> call(**kwargs)
INTERNALERROR> File “/usr/local/python/lib/python3.8/site-packages/xdist/dsession.py”, line 174, in worker_workerfinished
INTERNALERROR> assert not crashitem, (crashitem, node)
INTERNALERROR> AssertionError: (‘djw/test_case/smart_school_sys/教务管理/教学管理/教学计划及模板/test_teach_plans_with_moulds.py::test_mould_preview’, )
INTERNALERROR> assert not ‘djw/test_case/smart_school_sys/教务管理/教学管理/教学计划及模板/test_teach_plans_with_moulds.py::test_mould_preview’
如图:

关闭