我有不同的python unitttest方法打包爲TestSuite,並且一個特定的測試方法看起來像例如如何從python中的測試方法中提取測試方法名稱
<input.MyTest testMethod=test_simple>
它看起來這是一個類(這個東西的類型是input.MyTest
),但有一個附加屬性(?)TestMethod的。
如何從屬性testMethod
(或其他內容)中提取名稱test_simple
?
測試代碼(MyTest.py)
class MyTest(unittest.TestCase):
def test_simple(self):
pass
套房代碼
from input import MyTest
suite = test.TestSuite()
suite.addTest(MyTest("test_simple"))
print suite._tests[0]
顯示你的代碼,通過不顯示它,你讓這個問題更容易回答。 –
我也想知道MyTest和MyClass的東西。請詳細說明! – Alfe