python pytest-parallel上的多线程错误

问题描述

这里是为测试 pytest-parallel 编写的文件


from time import sleep
import threading

def test_1():
    sleep(2)


def test_2():
    sleep(3)

但是当我输入命令来运行它时,它似乎不起作用,这是commeng:


pytest test_parallel.py  --tests-per-worker 3

错误如下:


平台 win32 -- Python 3.8.6rc1、pytest-6.2.4、py-1.10.0、pluggy-0.13.1

rootdir: E:\auto_learn\autonatic_test\my_pytest 插件:forked-1.3.0、html-3.1.1、Metadata-1.11.0、parallel-0.1.0、rerunfailures-10.1、xdist-2.3.0 收集了 3 件物品
pytest-parallel:1 个工人(进程),每个工人 2 个测试(线程) INTERNALERROR> 回溯(最近一次调用最后一次): INTERNALERROR> File "d:\install\lib\site-packages_pytest\main.py",line 269,in wrap_session 内部错误> session.exitstatus = doit(config,session) 或 0 内部错误> 文件“d:\install\lib\site-packages_pytest\main.py”,第 323 行,在 _main 内部错误> config.hook.pytest_runtestloop(session=session) INTERNALERROR> 文件“d:\install\lib\site-packages\pluggy\hooks.py”,第 286 行,调用 内部错误> 返回 self._hookexec(self,self.get_hookimpls(),kwargs) 内部错误> 文件“d:\install\lib\site-packages\pluggy\manager.py”,第 93 行,在 _hookexec 内部错误> 返回 self._inner_hookexec(hook,methods,kwargs) 内部错误> 文件“d:\install\lib\site-packages\pluggy\manager.py”,第 84 行,在 内部错误> self._inner_hookexec = lambda 钩子、方法kwargs:hook.multicall( 内部错误> 文件“d:\install\lib\site-packages\pluggy\callers.py”,第 208 行,在 _multicall 内部错误> 返回结果.get_result() 内部错误> 文件“d:\install\lib\site-packages\pluggy\callers.py”,第 80 行,在 get_result 中 内部错误> 引发 ex[1].with_traceback(ex[2]) INTERNALERROR> 文件“d:\install\lib\site-packages\pluggy\callers.py”,第 187 行,multicall 内部错误> res = hook_impl.function(*args) 内部错误> 文件“d:\install\lib\site-packages\pytest_parallel_init.py”,第 302 行,在 pytest_runtestloop 中 内部错误> process.start() INTERNALERROR> File "d:\install\lib\multiprocessing\process.py",line 121,in start 内部错误> self._popen = self._Popen(self) 内部错误> 文件“d:\install\lib\multiprocessing\context.py”,第 224 行,在 _Popen 内部错误> 返回 _default_context.get_context().Process._Popen(process_obj) 内部错误> 文件“d:\install\lib\multiprocessing\context.py”,第 327 行,在 _Popen 内部错误> 返回 Popen(process_obj) INTERNALERROR> 文件“d:\install\lib\multiprocessing\popen_spawn_win32.py”,第 93 行,init 内部错误>reduction.dump(process_obj,to_child) 内部错误> 转储中的文件“d:\install\lib\multiprocessing\reduction.py”,第 60 行 内部错误> ForkingPickler(file,protocol).dump(obj) INTERNALERROR> AttributeError: 无法腌制本地对象 'ArgumentParser.init..identity'

    ======================no tests ran in 0.06s =======================
    Exception in thread Thread-1:
    Traceback (most recent call last):
      File "d:\install\lib\multiprocessing\connection.py",line 312,in _recv_bytes
        nread,err = ov.GetoverlappedResult(True)
    brokenPipeError: [WinError 109] 管道已结束。
    
    During handling of the above exception,another exception occurred:
    
    Traceback (most recent call last):
      File "d:\install\lib\threading.py",line 932,in _bootstrap_inner
    
    E:\auto_learn\autonatic_test\my_pytest>Traceback (most recent call last):
      File "<string>",line 1,in <module>
      File "d:\install\lib\multiprocessing\spawn.py",line 102,in spawn_main
        source_process = _winapi.OpenProcess(
    OSError: [WinError 87] 参数错误。
    from time import sleep
    'from' 不是内部或外部命令,也不是可运行的程序
    或批处理文件。
    
    E:\auto_learn\autonatic_test\my_pytest>import threading
    'import' 不是内部或外部命令,也不是可运行的程序
    或批处理文件。
    
    E:\auto_learn\autonatic_test\my_pytest>
    E:\auto_learn\autonatic_test\my_pytest>def test_1():
    'def' 不是内部或外部命令,也不是可运行的程序
    或批处理文件。
    
    E:\auto_learn\autonatic_test\my_pytest>    sleep(2)
    'sleep' 不是内部或外部命令,也不是可运行的程序
    或批处理文件。
    
    E:\auto_learn\autonatic_test\my_pytest>
    E:\auto_learn\autonatic_test\my_pytest>
    E:\auto_learn\autonatic_test\my_pytest>def test_2():
    'def' 不是内部或外部命令,也不是可运行的程序
    或批处理文件。
    
    E:\auto_learn\autonatic_test\my_pytest>    sleep(3)
    'sleep' 不是内部或外部命令,也不是可运行的程序
    或批处理文件

有人遇到过这种情况吗?任何我会appriciate的建议!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)