numpy.testing.print_assert_equal#

testing.print_assert_equal(test_string, actual, desired)[源代码]#

测试两个对象是否相等,如果测试失败,则打印错误消息.

使用 actual == desired 执行测试.

参数:
test_stringstr

提供给 AssertionError 的消息.

actualobject

用于测试与 desired 相等的对象.

desiredobject

期望的结果.

示例

>>> np.testing.print_assert_equal('Test XYZ of func xyz', [0, 1], [0, 1])
>>> np.testing.print_assert_equal('Test XYZ of func xyz', [0, 1], [0, 2])
Traceback (most recent call last):
...
AssertionError: Test XYZ of func xyz failed
ACTUAL:
[0, 1]
DESIRED:
[0, 2]