numpy.testing.assert_string_equal#

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

测试两个字符串是否相等.

如果给定的字符串相等,`assert_string_equal` 什么也不做.如果不相等,则会引发 AssertionError,并显示字符串之间的差异.

参数:
actualstr

用于与预期字符串进行相等性测试的字符串.

desiredstr

预期的字符串.

示例

>>> np.testing.assert_string_equal('abc', 'abc')
>>> np.testing.assert_string_equal('abc', 'abcd')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
...
AssertionError: Differences in strings:
- abc+ abcd?    +