python3 测试函数的一个例子
生活随笔
收集整理的這篇文章主要介紹了
python3 测试函数的一个例子
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
文件1.py
from fun import find_large import unittest #define a inherit class #father class is unittest.TestCase #which is a class of unittest class TestFuntion(unittest.TestCase): #define a method of the class #which has one parameter selfdef test_large(self): #calculate a data from outside function which will be testedlarge = find_large(12,10) #use a assert of the class you defined by yourselfself.assertEqual(large,12) #call the function main() from unittest unittest.main()文件fun.py
def find_large(num1,num2):if num1 >= num2:return num1else:return num2?
總結(jié)
以上是生活随笔為你收集整理的python3 测试函数的一个例子的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C++ remove、remove_co
- 下一篇: c++ 特定容器算法(sort,merg