社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

Python中带If-Else条件的单元测试

Damien • 3 年前 • 1111 次点击  

假设我们有以下功能:

import unittest
def func_test():
    indicator = True
    if(indicator == True):
        a = 5
        b = 10
        total = a+b
        return total
    else:
        a = 6
        b = 10
        total = a*b
        return total


class TestJob(unittest.TestCase)
    
    total = func_test(indicator = True)
    def test_func_test(self):
        self.assertGreater(total, 0)

我们如何测试 else 单元测试的条件?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/129997
 
1111 次点击  
文章 [ 1 ]  |  最新文章 3 年前