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> 

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

相关推荐
挽风82117 小时前
Pytest自动化框架
自动化·pytest·模块测试
Xiaoshuang_Cao1 天前
pytest结合allure
pytest
摸鱼仙人~2 天前
结合unittest和pytest进行虚拟数据库测试
数据库·windows·pytest
江梦寻4 天前
如何使用 Python+Flask+win32print 实现简易网络打印服务
开发语言·后端·python·flask·pytest·web3.py·win32
qq_白羊座4 天前
pytest框架 核心知识的系统复习
pytest
@TangXin4 天前
单元测试-pytest框架实践
自动化测试·单元测试·pytest
evelol75 天前
【pytest框架源码分析四】pluggy源码分析之hook执行
自动化·pytest
云泽野7 天前
Pytest之parametrize参数化
android·python·pytest
evelol77 天前
【pytest框架源码分析三】pluggy源码分析之hook注册调用流程
自动化·pytest
云泽野8 天前
【Pytest】setup和teardown的四个级别
pytest