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> 

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

相关推荐
头疼的程序员1 天前
allure生成测试报告(搭配Pytest、allure-pytest)
测试工具·pytest
文人sec2 天前
接口自动化测试设计思路--设计实战
python·https·单元测试·自动化·pytest
测试开发Kevin3 天前
从投入产出、效率、上手难易度等角度综合对比 pytest 和 unittest 框架
python·pytest
测试开发Kevin5 天前
以pytest_addoption 为例,讲解pytest框架中钩子函数的应用
python·pytest
川石教育11 天前
Pytest中的fixture装饰器详解
python自动化测试·pytest·pytest自动化测试框架·pytest测试框架·pytest单元测试框架
春风又。11 天前
接口自动化——参数化
python·测试工具·自动化·pytest
XTY0014 天前
mac电脑pytest生成测试报告
pytest
程序员的世界你不懂14 天前
pytest-前后置及fixture运用
pytest
天才测试猿15 天前
基于Pytest接口自动化的requests模块项目实战以及接口关联方法详解
自动化测试·软件测试·python·测试工具·单元测试·测试用例·pytest
HtwHUAT16 天前
五、UI自动化测试05--PyTest框架
经验分享·python·ui·pytest