Все пропущенные тесты хранятся в виде кортежей по именам в списке skipped
в атрибуте result
объекта TestProgram
, который unittest.main()
возвращает:
import unittest
import sys
class MyTestCase(unittest.TestCase):
@unittest.skip("I don't want to do it")
def test_nothing(self):
self.fail("shouldn't happen")
def test_something(self):
self.assertTrue(True)
test = unittest.main(exit=False) # do not exit after testing is done
sys.stdout.flush() # flush stdout so that the following output will be at the end
for name, reason in test.result.skipped:
print(name, reason)
Это выводит:
s.
----------------------------------------------------------------------
Ran 2 tests in 0.000s
OK (skipped=1)
test_nothing (__main__.MyTestCase) I don't want to do it