我是 python 新手,正在尝试运行单元测试。我的功能在使用 print 方法时运行良好,但在尝试开发测试模块时,我不断出错。
我在 python 文件中的函数(work.py)
def lee(n):
for i in range(1,n+1):
print (i)
我的单元测试模块
import unittest
import work
class TestWork(unittest.TestCase):
def test_lee(self):
result = work.lee(3)
self.assertEqual(result, [1,2,3])
if __name__ == '__main__':
unittest.main()
产生的错误
======================================================================
FAIL: test_lee (__main__.TestWork)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\test_work.py", line
12, in test_lee
self.assertEqual(result, [1,2,3])
AssertionError: None != [1, 2, 3]