Skip to content

STYLE pre-commit check to ensure that test functions name starts with test #50397

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

Merged

Conversation

MarcoGorelli
Copy link
Member

@MarcoGorelli MarcoGorelli force-pushed the check-test-funcs-classes-naming branch from 18bd5f4 to e13b5a8 Compare December 22, 2022 16:44
@@ -113,10 +113,11 @@ def test_read_columns(self):
columns = ["col1", "col3"]
self.check_round_trip(df, expected=df[columns], columns=columns)

def read_columns_different_order(self):
def test_read_columns_different_order(self):
Copy link
Member Author

Choose a reason for hiding this comment

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

@alimcmaster1 this test was never running because its name didn't start with test_ (just FYI, no blame!)

@@ -1323,10 +1323,6 @@ def test_period_can_hold_element(self, element):
elem = element(dti)
self.check_series_setitem(elem, pi, False)

def check_setting(self, elem, index: Index, inplace: bool):
Copy link
Member Author

Choose a reason for hiding this comment

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

helper function which wasn't being used anymore

Copy link
Member Author

Choose a reason for hiding this comment

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

@jbrockmendel looks like it was added in https://github.com/pandas-dev/pandas/pull/39120/files - do you remember if it was meant to be used anywhere?

Copy link
Member

Choose a reason for hiding this comment

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

Looks like it was meant to de-duplicate something but never got used. Rip it out!

@@ -1350,23 +1346,6 @@ def check_series_setitem(self, elem, index: Index, inplace: bool):
else:
assert ser.dtype == object

def check_frame_setitem(self, elem, index: Index, inplace: bool):
Copy link
Member Author

Choose a reason for hiding this comment

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

helper function which wasn't being used anymore

@@ -11,7 +11,13 @@
_testing as tm,
concat,
)
from pandas.tests.strings.test_strings import assert_series_or_index_equal
Copy link
Member Author

Choose a reason for hiding this comment

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

this function was defined in another file, but only used here. so, just moving it here

@@ -30,13 +30,18 @@
YearEnd,
)

from pandas.tests.tseries.offsets.test_offsets import get_utc_offset_hours
Copy link
Member Author

Choose a reason for hiding this comment

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

defined in another file, but only used here. so, let's just define it here

Comment on lines +344 to +345
^pandas/tests/generic/test_generic.py # GH50380
|^pandas/tests/io/json/test_readlines.py # GH50378
Copy link
Member Author

Choose a reason for hiding this comment

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

these exclusions will be removed as they're addressed

@MarcoGorelli MarcoGorelli marked this pull request as ready for review December 22, 2022 16:48
@MarcoGorelli MarcoGorelli marked this pull request as draft December 22, 2022 16:49
@MarcoGorelli MarcoGorelli marked this pull request as ready for review December 22, 2022 16:54
@MarcoGorelli MarcoGorelli added Code Style Code style, linting, code_checks Testing pandas testing functions or related to the test suite labels Dec 22, 2022
@MarcoGorelli MarcoGorelli force-pushed the check-test-funcs-classes-naming branch from 7d2cce3 to 30277d2 Compare December 22, 2022 21:00
and names.count(node.name) == 0
and not any(_is_fixture(decorator) for decorator in node.decorator_list)
and PRAGMA not in line
and not node.name.startswith("_")
Copy link
Member

Choose a reason for hiding this comment

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

I guess there could be a function called def _test_thing was was meant to be a test but maybe it's not worth worrying about?

Copy link
Member Author

Choose a reason for hiding this comment

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

good point actually - the three functions which this check found which started with underscores looked like helper functions, but were all unused. So, let's just remove them

Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

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

Nice! LGTM

@MarcoGorelli MarcoGorelli merged commit 1b653b1 into pandas-dev:main Dec 24, 2022
@MarcoGorelli
Copy link
Member Author

Just for the record - my hope is that we can eventually get to 100% coverage, and that then this tool wouldn't be necessary

But in the meantime, it takes ~3 seconds to run on CI, and can help identify issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Style Code style, linting, code_checks Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

STYLE pre-commit check to ensure that test functions name starts with test
3 participants