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('符合条件就跳过')
相关推荐
Warson_L13 小时前
Python `Annotated` 与 LangGraph Reducer 学习笔记
python
韩师傅13 小时前
海天线算法的前世今生
python·计算机视觉
韩师傅13 小时前
当你的甲方设备过烂,要如何快速出效果?
python·计算机视觉
Warson_L13 小时前
LangGraph的MessageState and HumanMessage
python
韩师傅13 小时前
当你的甲方吐槽天空不够蓝,你应该如何应对
python·计算机视觉
Warson_L14 小时前
python的类&继承
python
Warson_L14 小时前
类型标注/type annotation
python
ThreeS16 小时前
手搓MiniVLA全实战教程-一步一步用pytorch解释原理与思路
人工智能·python
金銀銅鐵18 小时前
[Python] 模 n 乘法的逆元计算器
python·数学·游戏