全栈自动化测试之pytest常用命令行参数_--multiproc是 python3

rootdir: D:\tools\pycharm\autotest
plugins: html-3.1.1, metadata-2.0.2
collected 7 items / 3 deselected / 4 selected

============================================================================================== 4/7 tests collected (3 deselected) in 1.88s ===============================================================================================

D:\tools\pycharm\autotest>pytest -k “test_ and _alias” --collect-only                                                         匹配包含test_  和  _alias的用例
========================================================================================================== test session starts ===========================================================================================================
platform win32 – Python 3.8.0, pytest-7.1.3, pluggy-1.0.0
rootdir: D:\tools\pycharm\autotest
plugins: html-3.1.1, metadata-2.0.2
collected 7 items / 6 deselected / 1 selected

============================================================================================== 1/7 tests collected (6 deselected) in 1.75s ===============================================================================================

-m 自定义标记执行

@pytest.mark.mark1
def test_create_article():

D:\tools\pycharm\autotest>pytest -m “mark1” --collect-only
========================================================================================================== test session starts ===========================================================================================================
platform win32 – Python 3.8.0, pytest-7.1.3, pluggy-1.0.0
rootdir: D:\tools\pycharm\autotest
plugins: html-3.1.1, metadata-2.0.2
collected 7 items / 6 deselected / 1 selected

============================================================================================== 1/7 tests collected (6 deselected) in 1.77s ===============================================================================================

-x 失败后立马结束运行

import pytest

class TestDemo:
    def test_one(self):
        assert True

    def test_two(self):
        assert False

    def test_three(self):
        assert True

    def test_four(self):
        assert True

D:\tools\pycharm\pythonProject1>pytest -x 自动化 -v
========================================================================================================== test session starts ===========================================================================================================
platform win32 – Python 3.8.0, pytest-7.1.3, pluggy-1.0.0 – d:\tools\python3.8\python.exe
cachedir: .pytest_cache
metadata: {‘Python’: ‘3.8.0’, ‘Platform’: ‘Windows-7-6.1.7601-SP1’, ‘Packages’: {‘pytest’: ‘7.1.3’, ‘py’: ‘1.11.0’, ‘pluggy’: ‘1.0.0’}, ‘Plugins’: {‘html’: ‘3.1.1’, ‘metadata’: ‘2.0.2’}, ‘JAVA_HOME’: ‘C:\Program Files (x86)\Java\jdk
1.8.0_111’}
rootdir: D:\tools\pycharm\pythonProject1
plugins: html-3.1.1, metadata-2.0.2
collected 4 items

自动化/测试pytest参数/test_demo.py::TestDemo::test_one PASSED [ 25%]
自动化/测试pytest参数/test_demo.py::TestDemo::test_two FAILED [ 50%]

================================================================================================================ FAILURES ================================================================================================================
___________________________________________________________________________________________________________ TestDemo.test_two ____________________________________________________________________________________________________________

self = <test_demo.TestDemo object at 0x00000000037463D0>

def test_two(self):

assert False
E assert False

自动化\测试pytest参数\test_demo.py:8: AssertionError
======================================================================================================== short test summary info =========================================================================================================
FAILED 自动化/测试pytest参数/test_demo.py::TestDemo::test_two - assert False
!!! stopping after 1 failures !!!
====================================================================================================== 1 failed, 1 passed in 0.43s =======================================================================================================

-v 显示执行的详细信息

D:\tools\pycharm\pythonProject1>pytest -x 自动化 -v
========================================================================================================== test session starts ===========================================================================================================
platform win32 – Python 3.8.0, pytest-7.1.3, pluggy-1.0.0 – d:\tools\python3.8\python.exe
cachedir: .pytest_cache
metadata: {‘Python’: ‘3.8.0’, ‘Platform’: ‘Windows-7-6.1.7601-SP1’, ‘Packages’: {‘pytest’: ‘7.1.3’, ‘py’: ‘1.11.0’, ‘pluggy’: ‘1.0.0’}, ‘Plugins’: {‘html’: ‘3.1.1’, ‘metadata’: ‘2.0.2’}, ‘JAVA_HOME’: ‘C:\Program Files (x86)\Java\jdk
1.8.0_111’}
rootdir: D:\tools\pycharm\pythonProject1
plugins: html-3.1.1, metadata-2.0.2
collected 4 items

自动化/测试pytest参数/test_demo.py::TestDemo::test_one PASSED [ 25%]
自动化/测试pytest参数/test_demo.py::TestDemo::test_two FAILED [ 50%]

–maxfail=num  最大失败次数,当超过最大失败次数就不在往下执行

D:\tools\pycharm\pythonProject1>pytest -v --maxfail=1 自动化
========================================================================================================== test session starts ===========================================================================================================
platform win32 – Python 3.8.0, pytest-7.1.3, pluggy-1.0.0 – d:\tools\python3.8\python.exe
cachedir: .pytest_cache
metadata: {‘Python’: ‘3.8.0’, ‘Platform’: ‘Windows-7-6.1.7601-SP1’, ‘Packages’: {‘pytest’: ‘7.1.3’, ‘py’: ‘1.11.0’, ‘pluggy’: ‘1.0.0’}, ‘Plugins’: {‘html’: ‘3.1.1’, ‘metadata’: ‘2.0.2’}, ‘JAVA_HOME’: ‘C:\Program Files (x86)\Java\jdk
1.8.0_111’}
rootdir: D:\tools\pycharm\pythonProject1
plugins: html-3.1.1, metadata-2.0.2
collected 4 items

自动化/测试pytest参数/test_demo.py::TestDemo::test_one PASSED [ 25%]
自动化/测试pytest参数/test_demo.py::TestDemo::test_two FAILED [ 50%]

================================================================================================================ FAILURES ================================================================================================================
___________________________________________________________________________________________________________ TestDemo.test_two ____________________________________________________________________________________________________________

self = <test_demo.TestDemo object at 0x0000000003744490>

def test_two(self):

assert False
E assert False

自动化\测试pytest参数\test_demo.py:8: AssertionError
======================================================================================================== short test summary info =========================================================================================================
FAILED 自动化/测试pytest参数/test_demo.py::TestDemo::test_two - assert False
!!! stopping after 1 failures !!!
====================================================================================================== 1 failed, 1 passed in 0.46s =======================================================================================================

D:\tools\pycharm\pythonProject1>

-s 代码中的打印输出

class TestDemo:
    def test_one(self):
        print("Hello test Demo one")
        assert True

D:\tools\pycharm\pythonProject1>pytest -v 自动化 -s
========================================================================================================== test session starts ===========================================================================================================
platform win32 – Python 3.8.0, pytest-7.1.3, pluggy-1.0.0 – d:\tools\python3.8\python.exe
cachedir: .pytest_cache
metadata: {‘Python’: ‘3.8.0’, ‘Platform’: ‘Windows-7-6.1.7601-SP1’, ‘Packages’: {‘pytest’: ‘7.1.3’, ‘py’: ‘1.11.0’, ‘pluggy’: ‘1.0.0’}, ‘Plugins’: {‘html’: ‘3.1.1’, ‘metadata’: ‘2.0.2’}, ‘JAVA_HOME’: ‘C:\Program Files (x86)\Java\jdk
1.8.0_111’}
rootdir: D:\tools\pycharm\pythonProject1
plugins: html-3.1.1, metadata-2.0.2
collected 4 items

自动化/测试pytest参数/test_demo.py::TestDemo::test_one Hello test Demo one
PASSED
自动化/测试pytest参数/test_demo.py::TestDemo::test_two FAILED
自动化/测试pytest参数/test_demo.py::TestDemo::test_three PASSED
自动化/测试pytest参数/test_demo.py::TestDemo::test_four FAILED

–lf 只运行失败的

D:\tools\pycharm\pythonProject1>pytest -v --lf 自动化

–ff   失败成功的都运行

D:\tools\pycharm\pythonProject1>pytest -v --ff 自动化

--tb=no  不显示具体的失败信息
pytest -v --tb=no 自动化



**(1)Python所有方向的学习路线(新版)**  

这是我花了几天的时间去把Python所有方向的技术点做的整理,形成各个领域的知识点汇总,它的用处就在于,你可以按照上面的知识点去找对应的学习资源,保证自己学得较为全面。

最近我才对这些路线做了一下新的更新,知识体系更全面了。



![在这里插入图片描述](https://img-blog.csdnimg.cn/1f807758e039481fa866130abf71d796.png#pic_center)



**(2)Python学习视频**



包含了Python入门、爬虫、数据分析和web开发的学习视频,总共100多个,虽然没有那么全面,但是对于入门来说是没问题的,学完这些之后,你可以按照我上面的学习路线去网上找其他的知识资源进行进阶。

![在这里插入图片描述](https://img-blog.csdnimg.cn/d66e3ad5592f4cdcb197de0dc0438ec5.png#pic_center)



**(3)100多个练手项目**

我们在看视频学习的时候,不能光动眼动脑不动手,比较科学的学习方法是在理解之后运用它们,这时候练手项目就很适合了,只是里面的项目比较多,水平也是参差不齐,大家可以挑自己能做的项目去练练。

![在这里插入图片描述](https://img-blog.csdnimg.cn/f5aeb4050ab547cf90b1a028d1aacb1d.png#pic_center)


  • 12
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值