Skip to content

CLN/DOC: fix test_register_entrypoint #46302

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
merged 1 commit into from
Mar 11, 2022

Conversation

graingert
Copy link
Contributor

@graingert graingert commented Mar 10, 2022

and cleanup tests eg #27517

# GH-28163
module = types.ModuleType("pandas_plot_backend")
sys.modules["pandas_plot_backend"] = module
Copy link
Contributor Author

Choose a reason for hiding this comment

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

pandas_plot_backend in sys.modules was leaked into other tests

@td.skip_if_no_mpl
def test_register_entrypoint(restore_backend):

dist = pkg_resources.get_distribution("pandas")
Copy link
Contributor Author

@graingert graingert Mar 10, 2022

Choose a reason for hiding this comment

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

this test was invalid because the underlying code uses importlib.metadata and not pkg_resources - so the pkg_resources.get_entry_map monkeypatch was unused.

however it passed because the entrypoint name matched the module name and so the code fell back to a regular import

@graingert graingert force-pushed the cleanup-pkg-resources-references branch 2 times, most recently from 881d1eb to 29e07aa Compare March 10, 2022 12:10
@@ -111,22 +116,49 @@ class BackendLoading:
warmup_time = 0

def setup(self):
dist = pkg_resources.get_distribution("pandas")
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 test was invalid because the underlying code uses importlib.metadata and not pkg_resources - so this pkg_resources.get_entry_map monkeypatch was unused.

It only passed because _get_plot_backend falls back to importlib.import_module

@graingert graingert changed the title cleanup pkg_resources references fix test_register_entrypoint Mar 10, 2022
by cleaning up all outdated references to pkg_resources
@graingert graingert force-pushed the cleanup-pkg-resources-references branch from 29e07aa to 80715e4 Compare March 10, 2022 12:16
@graingert graingert changed the title fix test_register_entrypoint CLN/DOC: fix test_register_entrypoint Mar 10, 2022
@graingert graingert marked this pull request as ready for review March 10, 2022 14:04
@mroeschke mroeschke added Testing pandas testing functions or related to the test suite Visualization plotting labels Mar 11, 2022
@mroeschke mroeschke added this to the 1.5 milestone Mar 11, 2022
@jreback jreback merged commit 8a489bd into pandas-dev:main Mar 11, 2022
@jreback
Copy link
Contributor

jreback commented Mar 11, 2022

thanks @graingert very nice

@graingert graingert deleted the cleanup-pkg-resources-references branch March 12, 2022 05:14
yehoshuadimarsky pushed a commit to yehoshuadimarsky/pandas that referenced this pull request Jul 13, 2022
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 Visualization plotting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants