2
測試看起來是這樣的:Pytest報告測試用unittest.skip跳過如通過
import unittest
class FooTestCase(unittest.TestCase):
@unittest.skip
def test_bar(self):
self.assertIsNone('not none')
當使用pytest
運行,該報告看起來是這樣的:
path/to/my/tests/test.py::FooTestCase::test_bar <- ../../../../../usr/lib/python3.5/unittest/case.py PASSED
。另一方面,如果我將@unittest.skip
替換爲@pytest.mark.skip
,則將其正確地報告爲跳過:
path/to/my/tests/test.py::FooTestCase::test_bar <- ../../../../../usr/lib/python3.5/unittest/case.py SKIPPED
如果有人能說,我做錯了什麼或者是pytest
中的錯誤?
看起來你需要調用'unittest.skip'。試試'@ unittest.skip()'。 –
vaultah