@@ -276,19 +276,6 @@ def test_numpy_array_equal_message(self):
276276 assert_almost_equal (np .array ([[1 , 2 ], [3 , 4 ]]),
277277 np .array ([[1 , 3 ], [3 , 4 ]]))
278278
279- expected = """numpy array are different
280-
281- numpy array values are different \\ (33\\ .33333 %\\ )
282- \\ [left\\ ]: \\ [á, à, ä\\ ]
283- \\ [right\\ ]: \\ [á, à, å\\ ]"""
284-
285- with tm .assert_raises_regex (AssertionError , expected ):
286- assert_numpy_array_equal (np .array ([u'á' , u'à' , u'ä' ]),
287- np .array ([u'á' , u'à' , u'å' ]))
288- with tm .assert_raises_regex (AssertionError , expected ):
289- assert_almost_equal (np .array ([u'á' , u'à' , u'ä' ]),
290- np .array ([u'á' , u'à' , u'å' ]))
291-
292279 # allow to overwrite message
293280 expected = """Index are different
294281
@@ -303,6 +290,24 @@ def test_numpy_array_equal_message(self):
303290 assert_almost_equal (np .array ([1 , 2 ]), np .array ([3 , 4 , 5 ]),
304291 obj = 'Index' )
305292
293+ def test_numpy_array_equal_unicode_message (self ):
294+ # Test ensures that `assert_numpy_array_equals` raises the right
295+ # exception when comparing np.arrays containing differing
296+ # unicode objects (#20503)
297+
298+ expected = """numpy array are different
299+
300+ numpy array values are different \\ (33\\ .33333 %\\ )
301+ \\ [left\\ ]: \\ [á, à, ä\\ ]
302+ \\ [right\\ ]: \\ [á, à, å\\ ]"""
303+
304+ with tm .assert_raises_regex (AssertionError , expected ):
305+ assert_numpy_array_equal (np .array ([u'á' , u'à' , u'ä' ]),
306+ np .array ([u'á' , u'à' , u'å' ]))
307+ with tm .assert_raises_regex (AssertionError , expected ):
308+ assert_almost_equal (np .array ([u'á' , u'à' , u'ä' ]),
309+ np .array ([u'á' , u'à' , u'å' ]))
310+
306311 @td .skip_if_windows
307312 def test_numpy_array_equal_object_message (self ):
308313
@@ -693,6 +698,11 @@ def test_frame_equal_message(self):
693698 pd .DataFrame ({'A' : [1 , 2 , 3 ], 'B' : [4 , 5 , 7 ]}),
694699 by_blocks = True )
695700
701+ def test_frame_equal_message_unicode (self ):
702+ # Test ensures that `assert_frame_equals` raises the right
703+ # exception when comparing DataFrames containing differing
704+ # unicode objects (#20503)
705+
696706 expected = """DataFrame\\ .iloc\\ [:, 1\\ ] are different
697707
698708DataFrame\\ .iloc\\ [:, 1\\ ] values are different \\ (33\\ .33333 %\\ )
0 commit comments