Skip to content
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

CLN: tests/extension/json/test_json.py typefix #28994

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions pandas/tests/extension/base/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@


class BaseExtensionTests:
@staticmethod
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you get rid of these methods altogether and just import / use as function within tests?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, since some tests need to override these

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm OK - so was this change required? Looks like using tm.assert_* in the tests now?

def assert_equal(left, right, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT it's only assert_series_equal and assert_frame_equal that currently need to be overridden in specific extension array tests, so assert_equal and assert_extension_array_equal don't need to be changed at this time.

tm.assert_equal(left, right, **kwargs)

assert_equal = staticmethod(tm.assert_equal)
assert_series_equal = staticmethod(tm.assert_series_equal)
assert_frame_equal = staticmethod(tm.assert_frame_equal)
assert_extension_array_equal = staticmethod(tm.assert_extension_array_equal)
@staticmethod
def assert_series_equal(left, right, **kwargs):
tm.assert_series_equal(left, right, **kwargs)

@staticmethod
def assert_frame_equal(left, right, **kwargs):
tm.assert_frame_equal(left, right, **kwargs)

@staticmethod
def assert_extension_array_equal(left, right, **kwargs):
tm.assert_extension_array_equal(left, right, **kwargs)
6 changes: 3 additions & 3 deletions pandas/tests/extension/json/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def assert_series_equal(self, left, right, **kwargs):
)
tm.assert_series_equal(left, right, **kwargs)

def assert_frame_equal(self, left, right, *args, **kwargs):
def assert_frame_equal(self, left, right, **kwargs):
tm.assert_index_equal(
left.columns,
right.columns,
Expand All @@ -108,11 +108,11 @@ def assert_frame_equal(self, left, right, *args, **kwargs):
jsons = (left.dtypes == "json").index

for col in jsons:
self.assert_series_equal(left[col], right[col], *args, **kwargs)
self.assert_series_equal(left[col], right[col], **kwargs)

left = left.drop(columns=jsons)
right = right.drop(columns=jsons)
tm.assert_frame_equal(left, right, *args, **kwargs)
tm.assert_frame_equal(left, right, **kwargs)


class TestDtype(BaseJSON, base.BaseDtypeTests):
Expand Down
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ ignore_errors=True
[mypy-pandas.tests.extension.json.array]
ignore_errors=True

[mypy-pandas.tests.extension.json.test_json]
ignore_errors=True

[mypy-pandas.tests.indexes.datetimes.test_datetimelike]
ignore_errors=True

Expand Down