test

1.importdoctest

参考https://blog.csdn.net/damotiansheng/article/details/44282691

2.classTestStatisticalFunctions(unittest.TestCase):

self.assertEqual(average([20,30,70]),40.0)

self.assertEqual(round(average([1,5,7]),1),4.3)

withself.assertRaises(ZeroDivisionError):

    average([])

self.assertRaises(ZeroDivisionError,average([]))

withself.assertRaises(TypeError):

    average(20,30,70)

self.assertRaises(TypeError,average(20, 30, 70))

你可能感兴趣的:(test)