有没有办法在 pycharm 中以详细模式运行单元测试。我正在寻找一种方法来查看测试函数中的文档字符串,以便我可以看到运行测试的一些信息。
class KnownValues(unittest.TestCase):
known_values = (
([1, 2],[[1, 2]]),
([1, 2, 3], [[1, 2], [1, 2, 3]]),
([1, 2, 3, 4],[[1, 2], [1, 2, 3, 4]]),
([1, 2, 3, 4, 5],[[1, 2], [1, 2, 3], [1, 2, 3, 4, 5]]),
([1, 2, 3, 4, 5, 6],[[1, 2], [1, 2, 3], [1, 2, 3, 4], [1, 2, 3, 4, 5, 6]]),
)
def test_check(self):
'''This should check is the function returning right'''
for arg, result in self.known_values:
print("Testing arg:{}".format(arg))
assert program.lister(arg) == result
if __name__ == '__main__':
unittest.main()
它返回:
Testing started at 19:38 ч. ...
Testing arg:[1, 2]
Process finished with exit code 0
我想得到:
test_check (__main__.KnownValues)
This should check is the function returning right ... Testing arg:[1, 2]
ok
----------------------------------------------------------------------
Ran 1 test in 0.001s
OK