【pytest在pycharm中运行与CMD命令运行区别一】

pytest在pycharm中运行与CMD命令运行区别一

pycharm下运行这段代码是如图1.1所示:

python 复制代码
import pytest


class Test01():
    def test_a(self):
        print('aaaa')
        assert 'a' == 'a'

    def test_b(self):
        print('bbbb')
        assert 'b' == 'b'


class Test02():
    def test_c(self):
        print('cccc')
        assert 'c' == 'c'

    def test_d(self):
        print('dddd')
        assert 'd' == 'd'


if __name__ == '__main__':
    pytest.main(["-s", "./test_11_11.py::Test02"])

图1.1

在CMD下运行是符合预期的。具体操作步骤如下:

图1.2

相关推荐
starzy19904 分钟前
深入理解Scala隐式参数:上下文流转
开发语言·python·scala
wuyk5551 小时前
Spider-第16讲-线程池与竞态问题
大数据·爬虫·python·elasticsearch·搜索引擎
kyle~7 小时前
FastAPI --- 将业务能力以 API 的形式提供给外部系统
python·fastapi·前后端
aiotto资源分享7 小时前
Python 写 JSON 文件,程序中途退出会留下什么?
java·python·json·jsondecodeerror
梯度下降者8 小时前
Python信号量,条件变量,事件学习
python·条件变量·事件·信号量·线程通信
MSTcheng.9 小时前
【AI应用实战】用 FastAPI + SSE 做一个自己的 AI 聊天网页:流式输出、多轮对话与完整源码
人工智能·python·大模型·fastapi·sse·ai聊天助手
the局外人10 小时前
Python 实战检索优化:BM25、向量与重排
数据库·后端·python
__underline__10 小时前
冷门Python知识点006篇:Python 类体里的名字,能被"凭空造出来"
后端·python
用户03321266636710 小时前
使用 Python 轻松移除 Excel 文档中的重复行
python·excel
LiaoWL12310 小时前
从零搭一个 RAG 知识库(二):换上语义 Embedding——BGE 实测与阈值重校准
python·大模型·numpy·embedding·向量检索·rag