Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python pytest xdist在使用多进程执行测试用例时崩溃_Python_Pytest - Fatal编程技术网

Python pytest xdist在使用多进程执行测试用例时崩溃

Python pytest xdist在使用多进程执行测试用例时崩溃,python,pytest,Python,Pytest,测试在没有pytest xdist的-n参数的情况下运行正常 但是,当我使用多个进程执行它时,即-n10,它会失败,并进行以下回溯 INTERNALERROR> Traceback (most recent call last): INTERNALERROR> File "c:\jay\work\automation\pytest-splunk-addon\new_dev_environment\pyparallel\lib\site-packages\_pytest\main.

测试在没有
pytest xdist
-n
参数的情况下运行正常

但是,当我使用多个进程执行它时,即
-n10
,它会失败,并进行以下回溯

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "c:\jay\work\automation\pytest-splunk-addon\new_dev_environment\pyparallel\lib\site-packages\_pytest\main.py", line 191, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "c:\jay\work\automation\pytest-splunk-addon\new_dev_environment\pyparallel\lib\site-packages\_pytest\main.py", line 247, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "c:\jay\work\automation\pytest-splunk-addon\new_dev_environment\pyparallel\lib\site-packages\pluggy\hooks.py", line 286, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "c:\jay\work\automation\pytest-splunk-addon\new_dev_environment\pyparallel\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "c:\jay\work\automation\pytest-splunk-addon\new_dev_environment\pyparallel\lib\site-packages\pluggy\manager.py", line 87, in <lambda>
INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR>   File "c:\jay\work\automation\pytest-splunk-addon\new_dev_environment\pyparallel\lib\site-packages\pluggy\callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "c:\jay\work\automation\pytest-splunk-addon\new_dev_environment\pyparallel\lib\site-packages\pluggy\callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "c:\jay\work\automation\pytest-splunk-addon\new_dev_environment\pyparallel\lib\site-packages\pluggy\callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "c:\jay\work\automation\pytest-splunk-addon\new_dev_environment\pyparallel\lib\site-packages\xdist\dsession.py", line 112, in pytest_runtestloop
INTERNALERROR>     self.loop_once()
INTERNALERROR>   File "c:\jay\work\automation\pytest-splunk-addon\new_dev_environment\pyparallel\lib\site-packages\xdist\dsession.py", line 135, in loop_once
INTERNALERROR>     call(**kwargs)
INTERNALERROR>   File "c:\jay\work\automation\pytest-splunk-addon\new_dev_environment\pyparallel\lib\site-packages\xdist\dsession.py", line 177, in worker_workerfinished
INTERNALERROR>     assert not crashitem, (crashitem, node)
INTERNALERROR> AssertionError: ('tests/test_my_addon.py::Test_App::test_props_fields_positive[splunkd::field::extractthree]', <WorkerController gw7>)

我的测试用例用字段列表参数化。问题似乎在于它。一旦我删除了类并使用了字典,测试就开始正常工作。

你是对的,错误太普遍了,不能说什么特别的东西(一个工人崩溃了b/c,引发了一个异常),所以请提供一个。谢谢你的回复。相信我,我正试图找到一个最小的可重复的例子。但即使要做到这一点,我也需要缩小可能性。为了缩小范围,我需要这个错误的可能原因。简言之,只要我找到最小的可复制示例,这个问题就会为我解决:)是的,我经常去那里——在每个插件hookimpl/函数中都有断点,检查最后访问的是什么并调试它。
class Field(object):
    """
        Contains the field properties

        Args:
            field_json (dict): dictionary containing field properties 
    """

    def __init__(self, field_json=None):
        self.name = field_json.get("name")
        self.field_type = field_json.get("field_type")
        self.expected_values = field_json.get("expected_values", ["*"])
        self.negative_values = field_json.get("negative_values", ["-", ""])
        self.condition = field_json.get("condition", ["-", ""])
        self.validity = field_json.get("validity", "")

    def __str__(self):
        return self.name