pytest报错_eclipse提交代码到git

pytest报错_eclipse提交代码到git前言我们每天写完自动化用例后都会提交到git仓库,随着用例的增多,为了保证仓库代码的干净,当有用例新增的时候,我们希望只运行新增的未提交git仓库的用例。pytest-picked插件可以

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

前言

我们每天写完自动化用例后都会提交到 git 仓库,随着用例的增多,为了保证仓库代码的干净,当有用例新增的时候,我们希望只运行新增的未提交 git 仓库的用例。pytest-picked 插件可以实现只运行未提交到git仓库的代码。
 

安装

pip3 install pytest-picked

 

使用示例

$ pytest --picked

$ pytest --picked=first

$ pytest --picked --mode=branch

$ pytest --picked --mode=unstaged  # default

$ pytest --picked --mode=branch --parent-branch=main # if your parent branch differs from "master"

 

–picked 参数

我们在已提交过 git 仓库的用例里面新增了 1 个文件 test_new.py
cd到项目根目录,使用git status查看当前分支状态

> git status

On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   case/test_new.py

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   case/test_new.py

可以看到有1个文件,使用 pytest –picked 运行用例

Changed test files... 1. ['case/test_new.py']
collecting ... 
 case/test_new.py ✓                                                                                                                                                                                      100% ██████████

Results (0.04s):
       1 passed

 

–picked=first

首先运行修改后的测试文件中的测试,然后运行所有未修改的测试
 

–mode=PICKED_MODE

–mode 有2个参数可选 unstaged, branch, 默认是–mode=unstaged

git 文件的2个状态

  • untrack 没加到git里面的新文件
  • unstaged staged:暂存状态, unstage就是未暂存状态,也就是没git add 过的文件
    先弄清楚什么是 untrack 状态,当我们 pycharm 打开 git 项目,新增一个文件的时候,会弹出询问框:是否加到 git 文件
    pytest报错_eclipse提交代码到git
    如果选择是,文件会变绿色,也就是 unstage 状态(没git add 过);选择否,那就是一个新文件,未被加到当前分支的 git 目录里面,文件颜色是棕色。
    git status 查看当前分支的状态,此时会看到 case/test_new2.py 是 Untracked files
> git status

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   case/test_new.py

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   case/test_new.py

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        case/test_new2.py

运行 pytest –picked 会默认执行所有的 Untracked 文件和 not staged 文件,默认是–mode=unstaged。

collecting ... 
 case/test_new2.py::test_2 ✓                                                                                                                                                                              50% █████     
 case/test_new.py::test_1 ✓                                                                                                                                                                              100% ██████████

如果我们只需运行当前分支上已经被暂存,但尚未提交的文件(不包含 Untracked files)
运行 pytest --picked --mode=branch, 运行分支上已经被暂存但尚未提交的代码

(pytest_env) ➜  apitest git:(master) ✗ pytest --picked --mode=branch

Changed test files... 1. ['case/test_new.py']
Changed test folders... 0. []
collecting ... 
 case/test_new.py::test_1 ✓                                                                                                                                                                              100% ██████████
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/165251.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • BIEE_biee报表日志

    BIEE_biee报表日志目录创建资料库创建物理模型创建逻辑模型创建展现模型保存资料库配置 OracleBIServer 使用新资料库在OracleAnswer中定义查询参考创建资料库BIEE的资料库(Repository)是一个后缀名为rpd的物理文件,其中存储了三类元数据:数据源物理模型,逻辑模型,以及展现模型。OracleBIServer是资料库的使用者:在前端,BI

    2025年8月22日
    5
  • Celer推出基于原子交换技术的跨链桥方案cBridge,今日主网上线

    Celer推出基于原子交换技术的跨链桥方案cBridge,今日主网上线据官方消息,CelercBridgev1.0版本今天正式主网上线。cBridge是一个支持高速低成本的跨链支付网络,用户可以立即使用cBridge在Ethereum、Arbitrum、BinanceSmartChain以及Polygon进行高速低成本跨链和跨层转账(cbridge.celer.network)。cBridge将会在短期内支持更多的layer2和layer1区块链的跨链和跨层转账。此外,任何人都将能够通过运行cBridge节点加入cBridge网络以提供跨链跨层流动性,同时通过收取手

    2022年5月4日
    46
  • 2022.3.5 PAT甲级 2022年春季考试 89分「建议收藏」

    2022.3.5PAT甲级2022年春季考试89分7-1SimpleLieDetection(20分)简单字符串问题,注意连续相同子段和连续上升子段的细节。#include<iostream>#include<cstdio>#include<string>usingnamespacestd;intmain(){ intn,t,k; strings; cin>>n>>t>>k; wh

    2022年4月11日
    81
  • c语言list的使用方法,c语言list操作

    c语言list的使用方法,c语言list操作#includetypedefstructLnode{intdata;structLnode*next;}LND,*lnd;lndmalloclist(lndl){l=(lnd)malloc(sizeof(LND));returnl;}intinitlist(lndl,intn){l->data=n;l->next=NULL;lndp;for(…

    2022年7月12日
    28
  • js漂浮广告代码_JavaScript上传文件代码

    js漂浮广告代码_JavaScript上传文件代码//浮动广告代码varx=50,y=60; //设置元素在浏览器窗口中的初始位置varxin=true,yin=true;//设置xin、yin用于判断元素是否在窗口范围内varstep=1; //可设置每次移动几像素varobj=document.getElementById(“Ad”);//通过id获取div元素functionfloatAd(){varL=T=0;varR=document.body.clientWidth-obj.off

    2026年2月4日
    7
  • 线程有哪些属性_thread runnable callable区别

    线程有哪些属性_thread runnable callable区别1、当在主线程中创建了一个线程,那么该线程的IsBackground默认是设置为FALSE的。2、当主线程退出的时候,IsBackground=FALSE的线程还会继续执行下去,直到线程执行结束。3、只有IsBackground=TRUE的线程才会随着主线程的退出而退出。4、当初始化一个线程,把Thread.IsBackground=true的时候,指示该线程为后台线程。后台线程将会随着主线程的退出而退出。5、原理:只要所有前台线程都终止后,CLR就会对每一个活在的后台线程调用Abort()

    2022年10月17日
    4

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号