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> 

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

相关推荐
兴趣使然黄小黄13 小时前
【Pytest】Pytest框架快速入门
python·pytest
m0_632482501 天前
Jenkins + Pytest +allure接口自动化测试配置与操作
jenkins·集成测试·pytest·jenkins配置
李星星BruceL1 天前
Pytest第三章(参考指南1)
python·自动化·pytest
哎呀呦呵1 天前
pytest基本使用
python·pytest
Kristen_YXQDN1 天前
PyCharm 中 pytest 运行 python 测试文件报错:D:\Python_file\.venv\Scripts\python.exe: No module named pytest
运维·开发语言·python·pycharm·pytest
Low--Key1 天前
pytest框架快速入门
python·自动化·pytest
姜西西_1 天前
自动化测试框架pytest之fixture
android·java·pytest
测试开发Kevin1 天前
超级实用!汇总pytest中那些常用的参数
单元测试·pytest
Beaman10241 天前
pytest框架
python·pytest
昔时扬尘处2 天前
【Files Content Replace】文件夹文件内容批量替换自动化测试脚本
c语言·python·pytest·adi