pytest xdist插件使用pytest\u addh选项非常规运行

2024-06-26 01:31:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在运行pytest\u addoption钩子和pytest xdist插件

def pytest_addoption(parser):
    parser.addoption("--env", action="append", default=[], help="list of env's to pass to test functions")

def pytest_generate_tests(metafunc):
    if 'env' in metafunc.fixturenames: metafunc.parametrize("env", metafunc.config.getoption('env'))

运行我的命令行就像。。。你知道吗

pytest tests/test_tests.py --tx popen//env:NAME=ENV1 --env "ENV1" --tx popen//env:NAME=ENV2 --env "ENV2" --dist=each

该命令与ENV1并行执行2次,与ENV2并行执行2次。不知道为什么!你知道吗

这是虫子吗?还是我执行错了?你知道吗

(venv) [tivo@localhost src]$ pytest tests/test_TC300457.py --tx popen//env:NAME=1 --env "micqe1" --tx popen//env:NAME=2 --env "micqe3" --dist=each
===================================================================== test    session starts     ======================================================================
platform linux -- Python 3.4.4, pytest-4.5.0, py-1.8.0, pluggy-0.11.0 -- /home/tivo/workspace/ServicePortal/autotestscripts/CAT/scripts/ServerQE/brat/venv/bin/python3
cachedir: .pytest_cache
rootdir: /home/tivo/workspace/ServicePortal/autotestscripts/CAT/scripts/ServerQE/brat/src, inifile: pytest.ini
plugins: xdist-1.28.0, remotedata-0.3.1, pipeline-0.3.0, parallel-0.0.9, forked-1.0.2, flake8-1.0.4, cov-2.7.1

[gw0] linux Python 3.4.4 cwd: /home/tivo/workspace/ServicePortal/autotestscripts/CAT/scripts/ServerQE/brat/src
[gw1] linux Python 3.4.4 cwd: /home/tivo/workspace/ServicePortal/autotestscripts/CAT/scripts/ServerQE/brat/src
[gw0] Python 3.4.4 (default, Mar 19 2018, 14:47:20)  -- [GCC 4.4.7 20120313 (Red Hat 4.4.7-18)]
[gw1] Python 3.4.4 (default, Mar 19 2018, 14:47:20)  -- [GCC 4.4.7 20120313 (Red Hat 4.4.7-18)]
gw0 [2] / gw1 [2]
scheduling tests via EachScheduling

  tests/test_TC300457.py::TestPortalSP01::test_TC_300457_ValidateAlerts[micqe1] 
[gw0] PASSED      tests/test_TC300457.py::TestPortalSP01::test_TC_300457_ValidateAlerts[micqe1] 
[gw1] PASSED     tests/test_TC300457.py::TestPortalSP01::test_TC_300457_ValidateAlerts[micqe1] 
tests/test_TC300457.py::TestPortalSP01::test_TC_300457_ValidateAlerts[micqe3] 
[gw0] PASSED     tests/test_TC300457.py::TestPortalSP01::test_TC_300457_ValidateAlerts[micqe3] 
[gw1] PASSED         tests/test_TC300457.py::TestPortalSP01::test_TC_300457_ValidateAlerts[micqe3] 


================================================================== 4 passed in 64.71 seconds ===================================================================
(venv) [tivo@localhost src]$ 

如您所见,我已经通过了4个测试用例,而我期望执行2个环境。你知道吗

还有两件事。你知道吗

  1. 无法获取日志,即使我在日志中添加了标志pytest.ini文件你知道吗

    [测试]

    addopts=-v-s

    log\ u cli=真

    log\u cli\u level=调试

    日志\级别=调试

日志被存放在什么地方了吗?你知道吗

  1. 这两个环境不是并行运行的。你知道吗

Tags: pytestsrcenvpytestteststctx
1条回答
网友
1楼 · 发布于 2024-06-26 01:31:13

我关闭这个,因为我得到了答案通过pytest并行插件。你知道吗

pytest tests/test_.py tests per worker auto env micqe3 env micqe1每个工人的测试

相关问题 更多 >