-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Safely raise errors when object contains unicode #20593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
9cd83ff
46cadc0
99ac0e8
329002c
b506cf6
8f607c3
6b087f2
51366f2
575b2e8
45d2b8e
1f7e231
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -276,6 +276,19 @@ def test_numpy_array_equal_message(self): | |
assert_almost_equal(np.array([[1, 2], [3, 4]]), | ||
np.array([[1, 3], [3, 4]])) | ||
|
||
expected = """numpy array are different | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you make a new test & indicate the gh issue with a comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 6b087f2 |
||
|
||
numpy array values are different \\(33\\.33333 %\\) | ||
\\[left\\]: \\[á, à, ä\\] | ||
\\[right\\]: \\[á, à, å\\]""" | ||
|
||
with tm.assert_raises_regex(AssertionError, expected): | ||
assert_numpy_array_equal(np.array([u"á", u"à", u"ä"]), | ||
np.array([u"á", u"à", u"å"])) | ||
with tm.assert_raises_regex(AssertionError, expected): | ||
assert_almost_equal(np.array([u"á", u"à", u"ä"]), | ||
np.array([u"á", u"à", u"å"])) | ||
|
||
# allow to overwrite message | ||
expected = """Index are different | ||
|
||
|
@@ -499,10 +512,12 @@ def _assert_not_equal(self, a, b, **kwargs): | |
def test_equal(self): | ||
self._assert_equal(Series(range(3)), Series(range(3))) | ||
self._assert_equal(Series(list('abc')), Series(list('abc'))) | ||
self._assert_equal(Series(list(u'áàä')), Series(list(u'áàä'))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add a test where left is unicode and right is non-unicode (but string) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 1f7e231 |
||
|
||
def test_not_equal(self): | ||
self._assert_not_equal(Series(range(3)), Series(range(3)) + 1) | ||
self._assert_not_equal(Series(list('abc')), Series(list('xyz'))) | ||
self._assert_not_equal(Series(list(u'áàä')), Series(list(u'éèë'))) | ||
self._assert_not_equal(Series(range(3)), Series(range(4))) | ||
self._assert_not_equal( | ||
Series(range(3)), Series( | ||
|
@@ -678,6 +693,21 @@ def test_frame_equal_message(self): | |
pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 7]}), | ||
by_blocks=True) | ||
|
||
expected = """DataFrame\\.iloc\\[:, 1\\] are different | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 6b087f2 |
||
|
||
DataFrame\\.iloc\\[:, 1\\] values are different \\(33\\.33333 %\\) | ||
\\[left\\]: \\[é, è, ë\\] | ||
\\[right\\]: \\[é, è, e̊\\]""" | ||
|
||
with tm.assert_raises_regex(AssertionError, expected): | ||
assert_frame_equal(pd.DataFrame({'A': [u"á", u"à", u"ä"], 'E': [u"é", u"è", u"ë"]}), | ||
pd.DataFrame({'A': [u"á", u"à", u"ä"], 'E': [u"é", u"è", u"e̊"]})) | ||
|
||
with tm.assert_raises_regex(AssertionError, expected): | ||
assert_frame_equal(pd.DataFrame({'A': [u"á", u"à", u"ä"], 'E': [u"é", u"è", u"ë"]}), | ||
pd.DataFrame({'A': [u"á", u"à", u"ä"], 'E': [u"é", u"è", u"e̊"]}), | ||
by_blocks=True) | ||
|
||
|
||
class TestAssertCategoricalEqual(object): | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is an internal function, rather say assert_series_equal and assert_frame_equal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 8f607c3