numpy.testing.assert_string_equal

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

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

如果给定的字符串相等, assert_string_equal 什么也不做。如果它们不相等,将引发断言错误,并显示字符串之间的差异。

参数
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?    +