Python基础学习019--跳过

python 复制代码
# 未完成的代码或不想让他执行的代码:使用装饰器跳过,书写在TestCase文件中
# 直接标记跳过:@unittest.skip('跳过原因')

# 根据条件判断跳过:@unittest.skipIf(判断条件,'跳过的原因'),跳进成立则跳过
import unittest

version = 31


class TestDemo(unittest.TestCase):
    @unittest.skip('没有原因,就是不让:')
    def test_1(self):
        print("不用判断就跳过")

    @unittest.skipIf(version >= 20, '20以后得版本不支持此功能')
    def test_2(self):
        print('符合条件就跳过')
相关推荐
geovindu37 分钟前
python: Face Recognition
开发语言·后端·python·人脸识别
2601_954811821 小时前
AI科学实验室MHS标准解读:AI智能体如何统一控制实验室设备接口
人工智能·python
一位正在转型AI全栈的前端工程师1 小时前
AI 全栈学习之旅 -Week 9:什么是AI Agent?从Function Calling到LangGraph
前端·python
用户0332126663671 小时前
使用 Python 为 PowerPoint 设置背景色和背景图【附代码示例】
python
ever_up9731 小时前
LangChain基础知识概述1
人工智能·python·langchain
asdzx672 小时前
Python 实现 PDF 文本查找与高亮标注
开发语言·python·pdf
zander2582 小时前
LeetCode 1143. 最长公共子序列
开发语言·python·算法
轩情吖2 小时前
Python基础知识点完整总结
python·字符串·编程语言·函数·列表·元组·字典
青 春 记 忆3 小时前
零基础入门python69:为 FastAPI 项目构建可复现 Docker 镜像
python·fastapi·后端开发
<花开花落>3 小时前
Python 项目迁移到 uv:经验小结与可复用工作流
python·uv