Last active
April 19, 2018 01:26
-
-
Save elmotec/f127e8536d6895280ce72d79c14a354b to your computer and use it in GitHub Desktop.
Handles pandas.DataFrame in unittest.TestCase.assertEqual()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add_data_frame_equality_func(test): | |
"""Define test class to handle assertEqual with `pandas.DataFrame`.""" | |
def frame_equal(lhs, rhs, msg=None): | |
"""Adapter for pandas.testing.assert_frame_equal.""" | |
if msg: | |
try: | |
pdt.assert_frame_equal(lhs, rhs) | |
except AssertionError as err: | |
raise test.failureException(msg) | |
else: | |
pdt.assert_frame_equal(lhs, rhs) | |
test.addTypeEqualityFunc(pd.DataFrame, frame_equal) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment