numpy.testing.print_assert_equal#
- testing.print_assert_equal(test_string, actual, desired)[源代码]#
测试两个对象是否相等,如果测试失败则打印错误信息.
测试是通过
actual == desired
进行的.- 参数:
- test_stringstr
提供给 AssertionError 的消息.
- actual对象
要与 desired 进行相等性测试的对象.
- desired对象
预期的结果.
示例
>>> 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]