Pytest框架直接右键运行 testcase.py,不执行最外层conftest

随笔记录

目录

[1. 背景介绍](#1. 背景介绍)

[2. workaround method](#2. workaround method)

[2.1 通过命令行执行 某个测试用例](#2.1 通过命令行执行 某个测试用例)


1. 背景介绍

Pytest 框架结构如下:
TestCases:
    conftest.py
    Instanta:    
        conftest.py
        test_instanta_tcpdump_pack_len.py

# 当直接右键直接 运行 test_instanta_tcpdump_pack_len.py 时,只运行Instanta\conftest.py,
不运行 TestCases\conftest.py.

2. workaround method

2.1 通过命令行执行 某个测试用例

# 命令行执行某个测试用例
# pytest -s .\TestCases\Instanta|test_instanta_tcpdump_Pack_length.py 


PS D:\Work\Git\NDPPBC1Card\BC1Card> 
PS D:\Work\Git\NDPPBC1Card\BC1Card> pytest -s .\TestCases\Instanta\test_instanta_Pack_Length.py
Send Server IP: 192.168.2.122
Send Server User: root                              
Send Server Password: 2023@Yusur122                 
Send Server dirVer: /magx/version/BC/BC-V1.0.7.1    
Send Server dirSdk: /magx/version/NDPP/NDPP-V1.0.7.1
Send Server scriptPath: /magx/test/BC1Card          
Send Server version: 1.0.7.1
Send Server Firmware_version: 04210007
Send Server Firmware_date: 24070301
Send Server cardType: X1100
======================================================================================================= test session starts =======================================================================================================
platform win32 -- Python 3.7.9, pytest-7.4.4, pluggy-1.2.0
......
......
......

================================================================================================= 1 passed, 4 warnings in 17.11s ================================================================================================== 
PS D:\Work\Git\NDPPBC1Card\BC1Card> 

到此暂时可以规避此问题。后续跟进中.....

相关推荐
神即道 道法自然 如来16 小时前
Python+Pytest框架,“main_run.py文件怎么编写“?
java·python·pytest
___Dream1 天前
【项目一】基于pytest的自动化测试框架———解读requests模块
python·计算机网络·pytest
ccy加油呀3 天前
pytest 接口测试
android·pytest
云泽野6 天前
一篇文章了解Pytest单元测试框架
服务器·单元测试·pytest
___Dream6 天前
【项目一】基于pytest的自动化测试框架day1
pytest
这不巧了7 天前
Faker在pytest中的应用
python·自动化·pytest
测试界的海飞丝7 天前
pytest运行方式及前置后置封装详解
开发语言·selenium·单元测试·pytest
什么时候才能变强7 天前
Pytest-@pytest.fixture夹具篇(一)
pytest
tester_sz9 天前
pytest钩子函数
开发语言·python·pytest
霍格沃兹测试开发学社测试人社区9 天前
软件测试学习笔记丨Pytest+Allure测试计算器
软件测试·笔记·测试开发·学习·pytest