Python单元测试框架


class
TestSequenceFunctions(unittest.TestCase): def setUp(self): self.seq = range(10) def test_shuffle(self): # make sure the shuffled sequence does not lose any elements random.shuffle(self.seq) self.seq.sort() self.assertEqual(self.seq, range(10)) # should raise an exception for an immutable sequence self.assertRaises
  • setUp: 在每个测试用例执行前执行
  • tearDown: 在每个测试用例执行后执行

 

posted @ 2017-05-30 13:06  剑尊  阅读(161)  评论(0编辑  收藏  举报