0
我寫了一個模塊,其中有幾個函數以及他們的doctests,我想運行這些測試的函數名稱相同,但是由其他人編寫。使用不同的函數運行doctests
的文檔提供了下面的代碼片段檢索所有測試中mymodule
somefunction
,然後以通常的方式運行它們(如跑步doctest.testmod()
):
TESTS = doctest.DocTestFinder().find(mymodule.somefunction)
DTR = doctest.DocTestRunner(verbose=True)
for test in TESTS:
print (test.name, '->', DTR.run(test))
但我不知道在哪裏何去何從代之以在theirmodule.somefunction
上運行這些測試。我試圖將filename
字段從mymodule
更改爲theirmodule
在Example
對象爲每個測試,但無濟於事。有誰知道如何做到這一點?