Skip to content

TST: fix casting extension tests for external users #41278

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

jorisvandenbossche
Copy link
Member

cc @simonjayhawkins fixtures defined by pandas are not known when inheriting the tests as external package. There are a bunch of fixtures that external packages are expected to define in pandas/tests/extension/conftest.py, but I think for the string dtype here this is not worth it to expect downstream users to define it themselves (certainly given that it is still going to change)

@jorisvandenbossche jorisvandenbossche added the Testing pandas testing functions or related to the test suite label May 3, 2021
@jorisvandenbossche jorisvandenbossche added this to the 1.3 milestone May 3, 2021
def test_astype_string(self, data, nullable_string_dtype):
# GH-33465
from pandas.core.arrays.string_arrow import ArrowStringDtype # noqa: F401
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

To force register the dtype, I think (the same reason that @simonjayhawkins also has been adding it in several places). AFAIU, once the ArrowStringDtype is merged with StringDtype, that will be done automatically and all those imports can be removed.

Copy link
Member

Choose a reason for hiding this comment

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

yep. these are removed in #39908

Copy link
Contributor

Choose a reason for hiding this comment

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

why can't you do the import IN the fixture itself? having in the test is very odd (when you also have the fixture)

Copy link
Member Author

Choose a reason for hiding this comment

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

There is no fixture to import it inside, only a pytest.mark.parametrize decorator

Copy link
Contributor

Choose a reason for hiding this comment

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

we do this type of thing in the parquet tests, need to do the same here

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you be more specific as "this type of thing in the parquet tests" ?

the nullable_string_dtype fixtures, sure there is

The whole point of this PR is to not use that, please look at the diff. I am removing the nullable_string_dtype fixture with a local parametrization

Copy link
Contributor

Choose a reason for hiding this comment

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

why, this is exactly the reason this fixture should exist. to avoid having to do a local import like this. which will surely be done incorrectly the next time. a fixture exists for exactly this reason.

Copy link
Member Author

Choose a reason for hiding this comment

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

The local imports are only temporary, they will be removed in #39908

Copy link
Contributor

Choose a reason for hiding this comment

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

ahh ok great

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 @jorisvandenbossche lgtm.

@jorisvandenbossche
Copy link
Member Author

Failure is the flaky ResourceWarning

@jreback jreback added the Strings String extension data type and string data label May 3, 2021
@jreback jreback merged commit 6b57a69 into pandas-dev:master May 3, 2021
@jorisvandenbossche jorisvandenbossche deleted the tests-extension-string-fixture branch May 3, 2021 14:40
yeshsurya pushed a commit to yeshsurya/pandas that referenced this pull request May 6, 2021
JulianWgs pushed a commit to JulianWgs/pandas that referenced this pull request Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Strings String extension data type and string data Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants