當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python numpy testing.run_module_suite用法及代碼示例

本文簡要介紹 python 語言中 numpy.testing.run_module_suite 的用法。

用法:

testing.run_module_suite(file_to_run=None, argv=None)

運行測試模塊。

相當於從命令行調用$ nosetests <argv> <file_to_run>

參數

file_to_run str,可選

測試模塊的路徑,或無。默認情況下,運行調用此函數的模塊。

argv 字符串列表

要傳遞給鼻子測試運行者的參數。 argv[0] 被忽略。 nosetests 接受的所有命令行參數都將起作用。如果是默認值 None,則使用sys.argv。

例子

添加以下內容:

if __name__ == "__main__" :
    run_module_suite(argv=sys.argv)

在測試模塊結束時,將在 python 解釋器中調用該模塊時運行測試。

或者,調用:

>>> run_module_suite(file_to_run="numpy/tests/test_matlib.py")

從解釋器將運行“test_matlib.py”中的所有測試例程。

相關用法


注:本文由純淨天空篩選整理自numpy.org大神的英文原創作品 numpy.testing.run_module_suite。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。