python单元测试unitest

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('每次结束前执行')

猜你喜欢

转载自www.cnblogs.com/jmwmj/p/9032936.html