码迷,mamicode.com
首页 > 编程语言 > 详细

python单元测试unitest

时间:2018-05-13 19:59:26      阅读:500      评论:0      收藏:0      [点我收藏+]

标签:模块   方法   def   imp   The   继承   elf   class   const   

import unittest


class TestDict(unittest.TestCase):

引用unitest模块,然后定义一个测试类,继承unitest.TestCase。

 

方法测试前置操作setup

def setUp(self):
    # Hook method for setting up the test fixture before exercising it.
    print(每次执行都先经过我)

 

方法测试后置操作

def tearDown(self):
    # Hook method for deconstructing the test fixture after testing it.
    print(每次结束前执行)

 

python单元测试unitest

标签:模块   方法   def   imp   The   继承   elf   class   const   

原文地址:https://www.cnblogs.com/jmwmj/p/9032936.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!