Pytest----repeat插件使用方法

简介: Pytest----repeat插件使用方法

【原文链接】

(1)安装pytest-repeat插件

(PytestEnv) G:\lamb_source\pytest_example_for_full_documentation\test_demo>pip install pytest-repeat
Collecting pytest-repeat
  Downloading pytest_repeat-0.8.0-py2.py3-none-any.whl (4.2 kB)
Requirement already satisfied: pytest>=3.6 in d:\miniconda\envs\pytestenv\lib\site-packages (from pytest-repeat) (5.4.3)
Requirement already satisfied: colorama; sys_platform == "win32" in d:\miniconda\envs\pytestenv\lib\site-packages (from pytest>=3.6->pytest-repeat) (0.4.3)
Requirement already satisfied: pluggy<1.0,>=0.12 in d:\miniconda\envs\pytestenv\lib\site-packages (from pytest>=3.6->pytest-repeat) (0.13.1)
Requirement already satisfied: packaging in d:\miniconda\envs\pytestenv\lib\site-packages (from pytest>=3.6->pytest-repeat) (20.4)
Requirement already satisfied: more-itertools>=4.0.0 in d:\miniconda\envs\pytestenv\lib\site-packages (from pytest>=3.6->pytest-repeat) (8.4.0)
Requirement already satisfied: py>=1.5.0 in d:\miniconda\envs\pytestenv\lib\site-packages (from pytest>=3.6->pytest-repeat) (1.9.0)
Requirement already satisfied: attrs>=17.4.0 in d:\miniconda\envs\pytestenv\lib\site-packages (from pytest>=3.6->pytest-repeat) (19.3.0)
Requirement already satisfied: atomicwrites>=1.0; sys_platform == "win32" in d:\miniconda\envs\pytestenv\lib\site-packages (from pytest>=3.6->pytest-repeat) (1.4.0)
Requirement already satisfied: wcwidth in d:\miniconda\envs\pytestenv\lib\site-packages (from pytest>=3.6->pytest-repeat) (0.2.5)
Requirement already satisfied: pyparsing>=2.0.2 in d:\miniconda\envs\pytestenv\lib\site-packages (from packaging->pytest>=3.6->pytest-repeat) (2.4.7)
Requirement already satisfied: six in d:\miniconda\envs\pytestenv\lib\site-packages (from packaging->pytest>=3.6->pytest-repeat) (1.15.0)
Installing collected packages: pytest-repeat
Successfully installed pytest-repeat-0.8.0

(2)使用 pytest -s –count=3 命令可以重复执行,不管结果成功还是失败

test_example.py中编写如下代码

def test_01():
    assert 1==1

def test_02():
    assert 1==2

重复执行的结果:

(PytestEnv) G:\lamb_source\pytest_example_for_full_documentation\test_demo>pytest -s --count=3
========================================================================= test session starts ==========================================================================
platform win32 -- Python 3.8.3, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: G:\lamb_source\pytest_example_for_full_documentation\test_demo
plugins: html-2.1.1, metadata-1.10.0, repeat-0.8.0
collected 6 items                                                                                                                                                       

test_example.py ...FFF

=============================================================================== FAILURES ===============================================================================
_____________________________________________________________________________ test_02[1-3] _____________________________________________________________________________

    def test_02():
>       assert 1==2
E       assert 1 == 2

test_example.py:7: AssertionError
_____________________________________________________________________________ test_02[2-3] _____________________________________________________________________________

    def test_02():
>       assert 1==2
E       assert 1 == 2

test_example.py:7: AssertionError
_____________________________________________________________________________ test_02[3-3] _____________________________________________________________________________

    def test_02():
>       assert 1==2
E       assert 1 == 2

test_example.py:7: AssertionError
======================================================================= short test summary info ========================================================================
FAILED test_example.py::test_02[1-3] - assert 1 == 2
FAILED test_example.py::test_02[2-3] - assert 1 == 2
FAILED test_example.py::test_02[3-3] - assert 1 == 2
===================================================================== 3 failed, 3 passed in 0.24s ======================================================================

(3)使用 pytest -s –count=3 -x 命令可以重复执行,直到失败位置,如果执行满三次了还没有失败,也不再继续了

test_example.py中编写如下代码:

def test_01():
    assert 1==1

def test_02():
    assert 1==2

使用如下命令执行:test_02因为第一次就失败了,所以不再继续执行了

pytest -s --count=3 -x

运行结果如下:

PytestEnv) G:\lamb_source\pytest_example_for_full_documentation\test_demo>pytest -s --count=3 -x
========================================================================= test session starts ==========================================================================
platform win32 -- Python 3.8.3, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: G:\lamb_source\pytest_example_for_full_documentation\test_demo
plugins: html-2.1.1, metadata-1.10.0, repeat-0.8.0
collected 6 items                                                                                                                                                       

test_example.py ...F

=============================================================================== FAILURES ===============================================================================
_____________________________________________________________________________ test_02[1-3] _____________________________________________________________________________

    def test_02():
>       assert 1==2
E       assert 1 == 2

test_example.py:6: AssertionError
======================================================================= short test summary info ========================================================================
FAILED test_example.py::test_02[1-3] - assert 1 == 2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
===================================================================== 1 failed, 3 passed in 0.18s ======================================================================

(4)使用装饰器标记重复执行的次数

在test_example.py中编写如下代码:

import pytest

def test_01():
    assert 1==1

@pytest.mark.repeat(3)
def test_02():
    assert 1==2

此时执行只需要使用 pytest -s即可,运行结果如下:

(PytestEnv) G:\lamb_source\pytest_example_for_full_documentation\test_demo>pytest -s
========================================================================= test session starts ==========================================================================
platform win32 -- Python 3.8.3, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: G:\lamb_source\pytest_example_for_full_documentation\test_demo
plugins: html-2.1.1, metadata-1.10.0, repeat-0.8.0
collected 4 items                                                                                                                                                       

test_example.py .FFF

=============================================================================== FAILURES ===============================================================================
_____________________________________________________________________________ test_02[1-3] _____________________________________________________________________________

    @pytest.mark.repeat(3)
    def test_02():
>       assert 1==2
E       assert 1 == 2

test_example.py:8: AssertionError
_____________________________________________________________________________ test_02[2-3] _____________________________________________________________________________

    @pytest.mark.repeat(3)
    def test_02():
>       assert 1==2
E       assert 1 == 2

test_example.py:8: AssertionError
_____________________________________________________________________________ test_02[3-3] _____________________________________________________________________________

    @pytest.mark.repeat(3)
    def test_02():
>       assert 1==2
E       assert 1 == 2

test_example.py:8: AssertionError
======================================================================= short test summary info ========================================================================
FAILED test_example.py::test_02[1-3] - assert 1 == 2
FAILED test_example.py::test_02[2-3] - assert 1 == 2
FAILED test_example.py::test_02[3-3] - assert 1 == 2
===================================================================== 3 failed, 1 passed in 0.19s ======================================================================

(5)重复执行类,只需要在类上加上装饰器即可

test_example.py 中编写如下代码:

import pytest

@pytest.mark.repeat(3)
class TestExample():
    def test_01(self):
        assert 1==1

    def test_02(self):
        assert 1==2

使用pytest -s执行结果如下:

(PytestEnv) G:\lamb_source\pytest_example_for_full_documentation\test_demo>pytest -s
========================================================================= test session starts ==========================================================================
platform win32 -- Python 3.8.3, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: G:\lamb_source\pytest_example_for_full_documentation\test_demo
plugins: html-2.1.1, metadata-1.10.0, repeat-0.8.0
collected 6 items                                                                                                                                                       

test_example.py ...FFF

=============================================================================== FAILURES ===============================================================================
_______________________________________________________________________ TestExample.test_02[1-3] _______________________________________________________________________

self = <test_example.TestExample object at 0x00000239A98BC370>

    def test_02(self):
>       assert 1==3
E       assert 1 == 3

test_example.py:9: AssertionError
_______________________________________________________________________ TestExample.test_02[2-3] _______________________________________________________________________

self = <test_example.TestExample object at 0x00000239A98CB6D0>

    def test_02(self):
>       assert 1==3
E       assert 1 == 3

test_example.py:9: AssertionError
_______________________________________________________________________ TestExample.test_02[3-3] _______________________________________________________________________

self = <test_example.TestExample object at 0x00000239A98CBAC0>

    def test_02(self):
>       assert 1==3
E       assert 1 == 3

test_example.py:9: AssertionError
======================================================================= short test summary info ========================================================================
FAILED test_example.py::TestExample::test_02[1-3] - assert 1 == 3
FAILED test_example.py::TestExample::test_02[2-3] - assert 1 == 3
FAILED test_example.py::TestExample::test_02[3-3] - assert 1 == 3
===================================================================== 3 failed, 3 passed in 0.23s ======================================================================

(6)pytest 命令行可通过 –repeat-scope指定重复执行的单元,可选值有:session,module,class,function

  • (1) function(默认)范围针对每个用例重复执行,再执行下一个用例
  • (2) class 以class为用例集合单位,重复执行class里面的用例,再执行下一个
  • (3) module 以模块为单位,重复执行模块里面的用例,再执行下一个
  • (4) session 重复整个测试会话,即所有收集的测试执行一次,然后所有这些测试再次执行等等

创建如下结构的文件:

test_demo
    |----test_example.py
    |----test_example_02.py

在两个py文件中都编写如下代码:

import pytest

def test_001():
    assert 1==1

def test_002():
    assert 1==2


class TestExample():
    def test_003(self):
        assert 3==3

    def test_004(self):
        assert 3==4

pytest -s –count=3 –repeat-scope=function 运行的结果如下,每个函数都运行三次后在进行下一个

(PytestEnv) G:\lamb_source\pytest_example_for_full_documentation\test_demo>pytest -s --count=3 --repeat-scope=function
========================================================================= test session starts ==========================================================================
platform win32 -- Python 3.8.3, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: G:\lamb_source\pytest_example_for_full_documentation\test_demo
plugins: html-2.1.1, metadata-1.10.0, repeat-0.8.0
collected 24 items                                                                                                                                                      

test_example.py ...FFF...FFF
test_example_02.py ...FFF...FFF

=============================================================================== FAILURES ===============================================================================
____________________________________________________________________________ test_002[1-3] _____________________________________________________________________________

    def test_002():
>       assert 1==2
E       assert 1 == 2

test_example.py:7: AssertionError
____________________________________________________________________________ test_002[2-3] _____________________________________________________________________________

    def test_002():
>       assert 1==2
E       assert 1 == 2

test_example.py:7: AssertionError
____________________________________________________________________________ test_002[3-3] _____________________________________________________________________________

    def test_002():
>       assert 1==2
E       assert 1 == 2

test_example.py:7: AssertionError
______________________________________________________________________ TestExample.test_004[1-3] _______________________________________________________________________

self = <test_example.TestExample object at 0x000001DD9BD0E730>

    def test_004(self):
>       assert 3==4
E       assert 3 == 4

test_example.py:15: AssertionError
______________________________________________________________________ TestExample.test_004[2-3] _______________________________________________________________________

self = <test_example.TestExample object at 0x000001DD9BCFBDF0>

    def test_004(self):
>       assert 3==4
E       assert 3 == 4

test_example.py:15: AssertionError
______________________________________________________________________ TestExample.test_004[3-3] _______________________________________________________________________

self = <test_example.TestExample object at 0x000001DD9BCFB460>

    def test_004(self):
>       assert 3==4
E       assert 3 == 4

test_example.py:15: AssertionError
____________________________________________________________________________ test_002[1-3] _____________________________________________________________________________

    def test_002():
>       assert 1==2
E       assert 1 == 2

test_example_02.py:7: AssertionError
____________________________________________________________________________ test_002[2-3] _____________________________________________________________________________

    def test_002():
>       assert 1==2
E       assert 1 == 2

test_example_02.py:7: AssertionError
____________________________________________________________________________ test_002[3-3] _____________________________________________________________________________

    def test_002():
>       assert 1==2
E       assert 1 == 2

test_example_02.py:7: AssertionError
______________________________________________________________________ TestExample.test_004[1-3] _______________________________________________________________________

self = <test_example_02.TestExample object at 0x000001DD9BD2E7C0>

    def test_004(self):
>       assert 3==4
E       assert 3 == 4

test_example_02.py:15: AssertionError
______________________________________________________________________ TestExample.test_004[2-3] _______________________________________________________________________

self = <test_example_02.TestExample object at 0x000001DD9BD9F6A0>

    def test_004(self):
>       assert 3==4
E       assert 3 == 4

test_example_02.py:15: AssertionError
______________________________________________________________________ TestExample.test_004[3-3] _______________________________________________________________________

self = <test_example_02.TestExample object at 0x000001DD9BD16DC0>

    def test_004(self):
>       assert 3==4
E       assert 3 == 4

test_example_02.py:15: AssertionError
======================================================================= short test summary info ========================================================================
FAILED test_example.py::test_002[1-3] - assert 1 == 2
FAILED test_example.py::test_002[2-3] - assert 1 == 2
FAILED test_example.py::test_002[3-3] - assert 1 == 2
FAILED test_example.py::TestExample::test_004[1-3] - assert 3 == 4
FAILED test_example.py::TestExample::test_004[2-3] - assert 3 == 4
FAILED test_example.py::TestExample::test_004[3-3] - assert 3 == 4
FAILED test_example_02.py::test_002[1-3] - assert 1 == 2
FAILED test_example_02.py::test_002[2-3] - assert 1 == 2
FAILED test_example_02.py::test_002[3-3] - assert 1 == 2
FAILED test_example_02.py::TestExample::test_004[1-3] - assert 3 == 4
FAILED test_example_02.py::TestExample::test_004[2-3] - assert 3 == 4
FAILED test_example_02.py::TestExample::test_004[3-3] - assert 3 == 4
==================================================================== 12 failed, 12 passed in 0.34s =====================================================================

pytest -s –count=3 –repeat-scope=class 运行结果如下,以类为单位进行重复执行3此,然后执行下一个类

(PytestEnv) G:\lamb_source\pytest_example_for_full_documentation\test_demo>pytest -s --count=3 --repeat-scope=class
========================================================================= test session starts ==========================================================================
platform win32 -- Python 3.8.3, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: G:\lamb_source\pytest_example_for_full_documentation\test_demo
plugins: html-2.1.1, metadata-1.10.0, repeat-0.8.0
collected 24 items                                                                                                                                                      

test_example.py .F.F.F.F.F.F
test_example_02.py .F.F.F.F.F.F

=============================================================================== FAILURES ===============================================================================
____________________________________________________________________________ test_002[1-3] _____________________________________________________________________________

    def test_002():
>       assert 1==2
E       assert 1 == 2

test_example.py:7: AssertionError
____________________________________________________________________________ test_002[2-3] _____________________________________________________________________________

    def test_002():
>       assert 1==2
E       assert 1 == 2

test_example.py:7: AssertionError
____________________________________________________________________________ test_002[3-3] _____________________________________________________________________________

    def test_002():
>       assert 1==2
E       assert 1 == 2

test_example.py:7: AssertionError
______________________________________________________________________ TestExample.test_004[1-3] _______________________________________________________________________

self = <test_example.TestExample object at 0x000001DAE249AB50>

    def test_004(self):
>       assert 3==4
E       assert 3 == 4

test_example.py:15: AssertionError
______________________________________________________________________ TestExample.test_004[2-3] _______________________________________________________________________

self = <test_example.TestExample object at 0x000001DAE24B0430>

    def test_004(self):
>       assert 3==4
E       assert 3 == 4

test_example.py:15: AssertionError
______________________________________________________________________ TestExample.test_004[3-3] _______________________________________________________________________

self = <test_example.TestExample object at 0x000001DAE24B0FA0>

    def test_004(self):
>       assert 3==4
E       assert 3 == 4

test_example.py:15: AssertionError
____________________________________________________________________________ test_002[1-3] _____________________________________________________________________________

    def test_002():
>       assert 1==2
E       assert 1 == 2

test_example_02.py:7: AssertionError
____________________________________________________________________________ test_002[2-3] _____________________________________________________________________________

    def test_002():
>       assert 1==2
E       assert 1 == 2

test_example_02.py:7: AssertionError
____________________________________________________________________________ test_002[3-3] _____________________________________________________________________________

    def test_002():
>       assert 1==2
E       assert 1 == 2

test_example_02.py:7: AssertionError
______________________________________________________________________ TestExample.test_004[1-3] _______________________________________________________________________

self = <test_example_02.TestExample object at 0x000001DAE24C30A0>

    def test_004(self):
>       assert 3==4
E       assert 3 == 4

test_example_02.py:15: AssertionError
______________________________________________________________________ TestExample.test_004[2-3] _______________________________________________________________________

self = <test_example_02.TestExample object at 0x000001DAE24C3F70>

    def test_004(self):
>       assert 3==4
E       assert 3 == 4

test_example_02.py:15: AssertionError
______________________________________________________________________ TestExample.test_004[3-3] _______________________________________________________________________

self = <test_example_02.TestExample object at 0x000001DAE24BD1C0>

    def test_004(self):
>       assert 3==4
E       assert 3 == 4

test_example_02.py:15: AssertionError
======================================================================= short test summary info ========================================================================
FAILED test_example.py::test_002[1-3] - assert 1 == 2
FAILED test_example.py::test_002[2-3] - assert 1 == 2
FAILED test_example.py::test_002[3-3] - assert 1 == 2
FAILED test_example.py::TestExample::test_004[1-3] - assert 3 == 4
FAILED test_example.py::TestExample::test_004[2-3] - assert 3 == 4
FAILED test_example.py::TestExample::test_004[3-3] - assert 3 == 4
FAILED test_example_02.py::test_002[1-3] - assert 1 == 2
FAILED test_example_02.py::test_002[2-3] - assert 1 == 2
FAILED test_example_02.py::test_002[3-3] - assert 1 == 2
FAILED test_example_02.py::TestExample::test_004[1-3] - assert 3 == 4
FAILED test_example_02.py::TestExample::test_004[2-3] - assert 3 == 4
FAILED test_example_02.py::TestExample::test_004[3-3] - assert 3 == 4
==================================================================== 12 failed, 12 passed in 0.26s =====================================================================

pytest -s –count=3 –repeat-scope=module运行结果如下:以模块为单位进行重复执行

========================================================================= test session starts ==========================================================================
platform win32 -- Python 3.8.3, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: G:\lamb_source\pytest_example_for_full_documentation\test_demo
plugins: html-2.1.1, metadata-1.10.0, repeat-0.8.0
collected 24 items                                                                                                                                                      

test_example.py .F.F.F.F.F.F
test_example_02.py .F.F.F.F.F.F

=============================================================================== FAILURES ===============================================================================
____________________________________________________________________________ test_002[1-3] _____________________________________________________________________________

    def test_002():
>       assert 1==2
E       assert 1 == 2

test_example.py:7: AssertionError
______________________________________________________________________ TestExample.test_004[1-3] _______________________________________________________________________

self = <test_example.TestExample object at 0x000001C76ED3D760>

    def test_004(self):
>       assert 3==4
E       assert 3 == 4

test_example.py:15: AssertionError
____________________________________________________________________________ test_002[2-3] _____________________________________________________________________________

    def test_002():
>       assert 1==2
E       assert 1 == 2

test_example.py:7: AssertionError
______________________________________________________________________ TestExample.test_004[2-3] _______________________________________________________________________

self = <test_example.TestExample object at 0x000001C76ED74D90>

    def test_004(self):
>       assert 3==4
E       assert 3 == 4

test_example.py:15: AssertionError
____________________________________________________________________________ test_002[3-3] _____________________________________________________________________________

    def test_002():
>       assert 1==2
E       assert 1 == 2

test_example.py:7: AssertionError
______________________________________________________________________ TestExample.test_004[3-3] _______________________________________________________________________

self = <test_example.TestExample object at 0x000001C76ED74D00>

    def test_004(self):
>       assert 3==4
E       assert 3 == 4

test_example.py:15: AssertionError
____________________________________________________________________________ test_002[1-3] _____________________________________________________________________________

    def test_002():
>       assert 1==2
E       assert 1 == 2

test_example_02.py:7: AssertionError
______________________________________________________________________ TestExample.test_004[1-3] _______________________________________________________________________

self = <test_example_02.TestExample object at 0x000001C76ED9D2E0>

    def test_004(self):
>       assert 3==4
E       assert 3 == 4

test_example_02.py:15: AssertionError
____________________________________________________________________________ test_002[2-3] _____________________________________________________________________________

    def test_002():
>       assert 1==2
E       assert 1 == 2

test_example_02.py:7: AssertionError
______________________________________________________________________ TestExample.test_004[2-3] _______________________________________________________________________

self = <test_example_02.TestExample object at 0x000001C76ED7D850>

    def test_004(self):
>       assert 3==4
E       assert 3 == 4

test_example_02.py:15: AssertionError
____________________________________________________________________________ test_002[3-3] _____________________________________________________________________________

    def test_002():
>       assert 1==2
E       assert 1 == 2

test_example_02.py:7: AssertionError
______________________________________________________________________ TestExample.test_004[3-3] _______________________________________________________________________

self = <test_example_02.TestExample object at 0x000001C76ED9D9A0>

    def test_004(self):
>       assert 3==4
E       assert 3 == 4

test_example_02.py:15: AssertionError
======================================================================= short test summary info ========================================================================
FAILED test_example.py::test_002[1-3] - assert 1 == 2
FAILED test_example.py::TestExample::test_004[1-3] - assert 3 == 4
FAILED test_example.py::test_002[2-3] - assert 1 == 2
FAILED test_example.py::TestExample::test_004[2-3] - assert 3 == 4
FAILED test_example.py::test_002[3-3] - assert 1 == 2
FAILED test_example.py::TestExample::test_004[3-3] - assert 3 == 4
FAILED test_example_02.py::test_002[1-3] - assert 1 == 2
FAILED test_example_02.py::TestExample::test_004[1-3] - assert 3 == 4
FAILED test_example_02.py::test_002[2-3] - assert 1 == 2
FAILED test_example_02.py::TestExample::test_004[2-3] - assert 3 == 4
FAILED test_example_02.py::test_002[3-3] - assert 1 == 2
FAILED test_example_02.py::TestExample::test_004[3-3] - assert 3 == 4
==================================================================== 12 failed, 12 passed in 0.28s =====================================================================

pytest -s –count=3 –repeat-scope=session 运行结果如下,以整个测试过程为单位重复执行3此

(PytestEnv) G:\lamb_source\pytest_example_for_full_documentation\test_demo>pytest -s --count=3 --repeat-scope=session
========================================================================= test session starts ==========================================================================
platform win32 -- Python 3.8.3, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: G:\lamb_source\pytest_example_for_full_documentation\test_demo
plugins: html-2.1.1, metadata-1.10.0, repeat-0.8.0
collected 24 items                                                                                                                                                      

test_example.py .F.F
test_example_02.py .F.F
test_example.py .F.F
test_example_02.py .F.F
test_example.py .F.F
test_example_02.py .F.F

=============================================================================== FAILURES ===============================================================================
____________________________________________________________________________ test_002[1-3] _____________________________________________________________________________

    def test_002():
>       assert 1==2
E       assert 1 == 2

test_example.py:7: AssertionError
______________________________________________________________________ TestExample.test_004[1-3] _______________________________________________________________________

self = <test_example.TestExample object at 0x0000018975001730>

    def test_004(self):
>       assert 3==4
E       assert 3 == 4

test_example.py:15: AssertionError
____________________________________________________________________________ test_002[1-3] _____________________________________________________________________________

    def test_002():
>       assert 1==2
E       assert 1 == 2

test_example_02.py:7: AssertionError
______________________________________________________________________ TestExample.test_004[1-3] _______________________________________________________________________

self = <test_example_02.TestExample object at 0x000001897504FD60>

    def test_004(self):
>       assert 3==4
E       assert 3 == 4

test_example_02.py:15: AssertionError
____________________________________________________________________________ test_002[2-3] _____________________________________________________________________________

    def test_002():
>       assert 1==2
E       assert 1 == 2

test_example.py:7: AssertionError
______________________________________________________________________ TestExample.test_004[2-3] _______________________________________________________________________

self = <test_example.TestExample object at 0x000001897504F130>

    def test_004(self):
>       assert 3==4
E       assert 3 == 4

test_example.py:15: AssertionError
____________________________________________________________________________ test_002[2-3] _____________________________________________________________________________

    def test_002():
>       assert 1==2
E       assert 1 == 2

test_example_02.py:7: AssertionError
______________________________________________________________________ TestExample.test_004[2-3] _______________________________________________________________________

self = <test_example_02.TestExample object at 0x0000018975060100>

    def test_004(self):
>       assert 3==4
E       assert 3 == 4

test_example_02.py:15: AssertionError
____________________________________________________________________________ test_002[3-3] _____________________________________________________________________________

    def test_002():
>       assert 1==2
E       assert 1 == 2

test_example.py:7: AssertionError
______________________________________________________________________ TestExample.test_004[3-3] _______________________________________________________________________

self = <test_example.TestExample object at 0x000001897505EC10>

    def test_004(self):
>       assert 3==4
E       assert 3 == 4

test_example.py:15: AssertionError
____________________________________________________________________________ test_002[3-3] _____________________________________________________________________________

    def test_002():
>       assert 1==2
E       assert 1 == 2

test_example_02.py:7: AssertionError
______________________________________________________________________ TestExample.test_004[3-3] _______________________________________________________________________

self = <test_example_02.TestExample object at 0x000001897505E670>

    def test_004(self):
>       assert 3==4
E       assert 3 == 4

test_example_02.py:15: AssertionError
======================================================================= short test summary info ========================================================================
FAILED test_example.py::test_002[1-3] - assert 1 == 2
FAILED test_example.py::TestExample::test_004[1-3] - assert 3 == 4
FAILED test_example_02.py::test_002[1-3] - assert 1 == 2
FAILED test_example_02.py::TestExample::test_004[1-3] - assert 3 == 4
FAILED test_example.py::test_002[2-3] - assert 1 == 2
FAILED test_example.py::TestExample::test_004[2-3] - assert 3 == 4
FAILED test_example_02.py::test_002[2-3] - assert 1 == 2
FAILED test_example_02.py::TestExample::test_004[2-3] - assert 3 == 4
FAILED test_example.py::test_002[3-3] - assert 1 == 2
FAILED test_example.py::TestExample::test_004[3-3] - assert 3 == 4
FAILED test_example_02.py::test_002[3-3] - assert 1 == 2
FAILED test_example_02.py::TestExample::test_004[3-3] - assert 3 == 4
==================================================================== 12 failed, 12 passed in 0.27s =====================================================================
目录
相关文章
|
测试技术
30-pytest-重复执行用例-pytest-repeat
30-pytest-重复执行用例-pytest-repeat
30-pytest-重复执行用例-pytest-repeat
|
测试技术
Pytest中skip和skipif的具体使用方法
Pytest中skip和skipif的具体使用方法
144 0
 Pytest中skip和skipif的具体使用方法
【pytest官方文档】解读fixtures - 2. fixtures的调用方式
【pytest官方文档】解读fixtures - 2. fixtures的调用方式
|
测试技术
Pytest----allure报告定制样式
Pytest----allure报告定制样式
456 0
Pytest----allure报告定制样式
|
测试技术 Python
Pytest系列(13)- 重复执行用例插件之pytest-repeat的详细使用
Pytest系列(13)- 重复执行用例插件之pytest-repeat的详细使用
269 0
Pytest系列(13)- 重复执行用例插件之pytest-repeat的详细使用
|
测试技术 TensorFlow 算法框架/工具
Pytest----如何使用skip和xfail
Pytest----如何使用skip和xfail
123 0
|
测试技术
Pytest----如何使用mark
Pytest----如何使用mark
362 0
|
测试技术
Pytest----定制自定义命令行参数
Pytest----定制自定义命令行参数
414 0
|
测试技术
Pytest----如何正确使用pytest的日志功能
Pytest----如何正确使用pytest的日志功能
517 0
|
Python
Pytest----如何安装和使用插件
Pytest----如何安装和使用插件
195 0