Skip to content

TST: Use indices fixture in tests/indexes/test_base.py #32963

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

SaturnFromTitan
Copy link
Contributor

@SaturnFromTitan SaturnFromTitan commented Mar 24, 2020

part of #30914

  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff

(parametrize over indices_dict keys with indirect=True). Defaults to string
index if no keys are provided.
"""
key = getattr(request, "param", "string")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line makes that using index without parametrization is identical to writing @pytest.mark.parametrize("indices", ["string"], indirect=True)

Copy link
Member

Choose a reason for hiding this comment

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

Thanks @SaturnFromTitan for doing this. This was intended to be a follow-up to #28865 #28865 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is now replaced by string_index

@SaturnFromTitan SaturnFromTitan added the Testing pandas testing functions or related to the test suite label Mar 24, 2020
@SaturnFromTitan SaturnFromTitan changed the title 30914 Use indices fixture in tests/indexes/test_base.py TST: Use indices fixture in tests/indexes/test_base.py Mar 24, 2020
@jbrockmendel
Copy link
Member

Something I've been trying to do that you might be interested in: these tests are a mix between using indices fixture and self.create_index. If we take all of the create_index methods and put those indexes into the indices fixture, then we can switch over completely to using the fixture.

@SaturnFromTitan
Copy link
Contributor Author

Good idea @jbrockmendel, I can look into that. Is there a ticket for replacing self.create_index?

Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

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

Thanks @SaturnFromTitan lgtm. could be a smaller diff with #28865 (comment) . wdyt?

(parametrize over indices_dict keys with indirect=True). Defaults to string
index if no keys are provided.
"""
key = getattr(request, "param", "string")
Copy link
Member

Choose a reason for hiding this comment

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

Thanks @SaturnFromTitan for doing this. This was intended to be a follow-up to #28865 #28865 (comment)

@simonjayhawkins simonjayhawkins added this to the 1.1 milestone Mar 24, 2020
@SaturnFromTitan
Copy link
Contributor Author

SaturnFromTitan commented Mar 24, 2020

+1 for renaming the fixture to index @simonjayhawkins

I wonder about a good transition strategy though. I could create a fixture index = indices in pandas/conftest.py and then follow-up with a few PRs that replace indices by index. Wdyt?

@simonjayhawkins
Copy link
Member

+1 for renaming the fixture to index @simonjayhawkins

I wonder about a good transition strategy though. I could create a fixture index = indices in pandas/conftest.py and then follow-up with a few PRs that replace indices by index. Wdyt?

sounds good. that'll keep the diff here smaller here while allowing others to give their opinions on naming fixtures in general before making changes to other modules.

@SaturnFromTitan
Copy link
Contributor Author

A much more digestible diff now @simonjayhawkins :)

@jbrockmendel
Copy link
Member

I find @pytest.mark.parametrize("index", ["string"], indirect=True) much less clear than index = tm.makeStringIndex(100)

@SaturnFromTitan
Copy link
Contributor Author

SaturnFromTitan commented Mar 24, 2020

@jbrockmendel I kinda agree. Instead of tm.makeStringIndex(100) we should use a string_index fixture though

@SaturnFromTitan
Copy link
Contributor Author

@jreback @jbrockmendel @simonjayhawkins
As there seems to be no consent for index as an alternative name for indices, I refrained from introducing an alternative name in this PR altogether. This PR is exclusively using the indices fixture now. The renaming should come in follow-up PRs.

@SaturnFromTitan
Copy link
Contributor Author

@jreback CI is finally green

@jreback
Copy link
Contributor

jreback commented Mar 29, 2020

sorry a small comment, also merge master and ping on green.

@SaturnFromTitan
Copy link
Contributor Author

@jreback Using indirect instead of a separate fixture now + CI is green

@jreback jreback merged commit 3a29263 into pandas-dev:master Mar 29, 2020
@jreback
Copy link
Contributor

jreback commented Mar 29, 2020

thanks!

I think it’s worth mentioning in our contributing docs on how - when to use indirect fixtures

@SaturnFromTitan
Copy link
Contributor Author

xref: #33128

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

Successfully merging this pull request may close these issues.

4 participants