numpy.testing.assert_string_equal#

testing.assert_string_equal(actual, desired)[source]#

測試兩個字串是否相等。

如果給定的字串相等,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?    +