numpy.testing.assert_raises_regex#

testing.assert_raises_regex(exception_class, expected_regexp, callable, *args, **kwargs) assert_raises_regex(exception_class, expected_regexp)[原始碼]#

若呼叫 callable 時,沒有拋出類別為 exception_class 且訊息符合 expected_regexp 的例外,則會失敗。callable 的呼叫會帶入參數 args 和關鍵字參數 kwargs。

或者,可以像 assert_raises 一樣作為上下文管理器使用。