Skip to content

TST: skip test if running non-installed #27810

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
Aug 13, 2019
Merged
Changes from all 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
10 changes: 7 additions & 3 deletions pandas/tests/plotting/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,18 @@ def test_backend_is_correct(monkeypatch):

@td.skip_if_no_mpl
Copy link
Contributor

Choose a reason for hiding this comment

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

why doesn't this work in this case?

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 issue is running the tests from a non-virtualenv-like setup. So matplotlib is installed, but the pandas being tested is not in site-packages

def test_register_entrypoint():

dist = pkg_resources.get_distribution("pandas")
if dist.module_path not in pandas.__file__:
# We are running from a non-installed pandas, and this test is invalid
pytest.skip("Testing a non-installed pandas")

mod = types.ModuleType("my_backend")
mod.plot = lambda *args, **kwargs: 1

backends = pkg_resources.get_entry_map("pandas")
my_entrypoint = pkg_resources.EntryPoint(
"pandas_plotting_backend",
mod.__name__,
dist=pkg_resources.get_distribution("pandas"),
"pandas_plotting_backend", mod.__name__, dist=dist
)
backends["pandas_plotting_backends"]["my_backend"] = my_entrypoint
# TODO: the docs recommend importlib.util.module_from_spec. But this works for now.
Expand Down