问题标签 [pytest-parallel]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
219 浏览

python - Py.Test 以编程方式调用时找不到 pytest-parallel

我正在尝试通过编程调用向pytest发送并行参数,但似乎根本无法识别它们,就像根本没有安装并行时那样,除了我知道存在,因为当我使用直接命令行调用运行py.test时,包括相同的论点,它会找到它并成功运行。

错误:用法:invoke_pytest.py [options] [file_or_dir] [file_or_dir] [...] invoke_pytest.py:错误:无法识别的参数:--workers 1 --tests-per-worker 4

这是我的代码:

虽然看起来不相关,但我也在为这个测试套件使用 py.test bdd 和 splinter。

0 投票
1 回答
1313 浏览

python - 如何运行一次设置(夹具)然后并行测试

我使用 pytest-xdist 并行运行测试,但我的套件设置非常庞大且笨重,我希望避免在每次测试执行中多次运行。
当我使用 pytest-xdist 并行运行所有测试时,我遇到了一个问题,即我的套件设置(夹具)在每次测试执行之前运行,这增加了所有测试用例的执行时间。
有什么方法可以避免在 pytest 并行执行中的每次测试执行之前执行夹具?

0 投票
0 回答
400 浏览

python - 并行测试函数调用的运行时统计信息(使用 pytest-benchmark 或其他插件)

我想使用一个插件来显示并行调用的pytest-benchmark运行时统计信息,...,。 test_valid_submission(0)test_valid_submission(EXPERIMENT_SIZE)

为此,我有以下代码,它尝试使用pytest-benchmark(类似于Grouping Parametrized Benchmarks with pytest)来实现这一点:

当我打电话

我希望最后得到一个基准汇总表EXPERIMENT_SIZE,其中包含我的并行test_valid_submission()调用的每个运行时的最小值、最大值、平均值、标准偏差。不幸的是,没有打印基准摘要表(请参阅下面的详细信息)。

@hoefling 评论pytest-benchmark说不支持并行运行和收集基准数据。

是否有另一个 pytest 插件(或其他解决方案)可以

  • 收集EXPERIMENT_SIZE并行test_valid_submission(x)调用的数量并将它们组合在一起
  • 计算组中并行调用的运行时统计的最小值、最大值、平均值、标准差
  • 使用多个组,例如一个 fortest_valid_submission(x)和一个 fortest_invalid_submission(x)
  • 在我的测试结束时打印统计信息,类似于上面提到的 pytest-benchmark 汇总表

关于 pytest-benchmark 的详细信息

使用pytest-benchmark、和EXPERIMENT_SIZE=3,我得到以下输出(但即使在 时,它也显示并且没有统计信息)。iterations=1rounds=1EXPERIMENT_SIZE>=5rounds=5

但我得到以下输出(EXPERIMENT_SIZE=3删除了不相关的行):

交替使用benchmark.pedantic(test_valid_submission, args=[counter], iterations=1, rounds=1)也不会导致打印统计数据。

0 投票
0 回答
320 浏览

pytest - pytest-parallel 不尊重模块范围的固定装置

假设我在文件中编写了以下测试用例test_something.py

当我使用以下命令运行上述pytest命令时,它们可以正常工作。

但是,我想以并行方式运行这些测试用例。我知道,test_1应该test_2并行运行。所以我查看了 pytest-parallel 并执行了以下操作:

但是如上面的代码所示,当它去创建/a/b/bin文件夹时,它会抛出一个错误,说该目录已经存在。所以这意味着模块范围在 pytest-parallel 中没有得到尊重。它正在尝试get_some_binary_file为每个参数化输入执行test_1我有没有办法做到这一点?

我还使用该--dist loadscope选项查看了 pytest-xdist,并为其运行了以下命令:

但这给了我一个如下所示的输出,其中test_1test_2都在同一个工人上执行。

从上面的输出可以看出,test_2gw1 正在运行。为什么?它不应该在不同的工人中运行吗?

0 投票
0 回答
165 浏览

python - python pytest-parallel上的多线程错误

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



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



错误出现如下:


平台 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 plugins: 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-并行:1 个工作人员(进程),每个工作人员(线程)进行 2 个测试INTERNALERROR> session.exitstatus = doit(config, session) or 0 INTERNALERROR> File "d:\install\lib\site-packages_pytest\main.py", line 323, in _main INTERNALERROR> config.hook.pytest_runtestloop(session=session ) INTERNALERROR> 文件“d:\install\lib\site-packages\pluggy\hooks.py”,第 286 行,调用中 INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs) INTERNALERROR> File "d:\install\lib\site-packages\pluggy\manager.py", line 93, in _hookexec INTERNALERROR> return self._inner_hookexec (hook, methods, kwargs) INTERNALERROR> 文件“d:\install\lib\site-packages\pluggy\manager.py”,第 84 行,在 INTERNALERROR> self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall( INTERNALERROR> 文件“d:\install\lib\site-packages\pluggy\callers.py”,第 208 行,在 _multicall INTERNALERROR> return results.get_result() INTERNALERROR> 文件“d:\install\lib\site-packages\ pluggy\callers.py",第 80 行,在 get_result INTERNALERROR> raise ex[1].with_traceback(ex[2]) INTERNALERROR> File "d:\install\lib\site-packages\pluggy\callers.py",第 187 行,在multicall INTERNALERROR> res = hook_impl.function(*args) INTERNALERROR> File "d:\install\lib\site-packages\pytest_parallel_init .py ", line 302, in pytest_runtestloop INTERNALERROR> process.start() INTERNALERROR> File "d :\install\lib\multiprocessing\process.py",第 121 行,在开始 INTERNALERROR> self._popen = self._Popen(self) INTERNALERROR> 文件“d:\install\lib\multiprocessing\context.py”,第 224 行,在 _Popen INTERNALERROR> return _default_context.get_context().Process._Popen(process_obj) INTERNALERROR> 文件“d:\install\lib\multiprocessing\context.py”,第 327 行,在 _Popen INTERNALERROR> return Popen(process_obj) INTERNALERROR>文件“d:\install\lib\multiprocessing\popen_spawn_win32.py”,第 93 行,在初始化 INTERNALERROR> reduction.dump(process_obj, to_child) INTERNALERROR> File "d:\install\lib\multiprocessing\reduction.py", line 60, in dump INTERNALERROR> ForkingPickler(file, protocol).dump(obj) INTERNALERROR> AttributeError:无法腌制本地对象 'ArgumentParser. 初始化..身份'


有没有人遇到过这样的事情?任何我会appriciate的建议!

0 投票
0 回答
8 浏览

multithreading - 使用动态预定义的线程名称运行在 pytest-parallel 中

我使用 pytest-parallel 插件(https://github.com/browsertron/pytest-parallel)并希望动态设置线程名称,例如:

但它总是卡在 Ubuntu 上。设置线程名称的正确方法是什么?你能帮忙吗?