我能想到的兩種方式,以確保我能在廣泛的Python版本使用現代特色從單元測試庫: try:
from unittest2 import TestCase
except ImportError:
from unittest import TestCase
或 import sys
if sys.verson_info.major>=2 and sys.version_in
我需要從每個測試之前unittest運行的SetUp()方法中找到將要運行的測試方法的名稱。我怎樣才能做到這一點,而不需要單獨運行每種測試方法? 例子: class Testing(unittest2.TestCase):
def setUp():
# wish i could write:
string = getNextTestMethodName()