Skip to content
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

Bugfix: add alternatives to fixture or raise exception #68

Merged
merged 3 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
name = "ensembl-py"
description = "Ensembl Python Base Library"
requires-python = ">= 3.8"
version = "1.4.1"
version = "1.4.2"
readme = "README.md"
authors = [
{name = "Ensembl", email = "[email protected]"},
Expand Down
20 changes: 19 additions & 1 deletion src/python/ensembl/plugins/pytest_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,26 @@ def shared_data_dir(pytestconfig: Config) -> Path:
Args:
pytestconfig: Session-scoped fixture that returns the session's `pytest.Config` object.

Raises:
IOError: If `[src/[python/]]tests/data` folder does not exists from the root of the repository.

"""
return pytestconfig.rootpath / "src/python/tests/data"
# Try to get the most likely place for the shared test data folder from the pyproject.toml file
test_paths = pytestconfig.getini("testpaths")
if test_paths:
return pytestconfig.rootpath / test_paths[0] / "data"
# If not defined, look for the expected places
shared_data_path = pytestconfig.rootpath / "src/python/tests/data"
if shared_data_path.is_dir():
return shared_data_path
shared_data_path = pytestconfig.rootpath / "src/tests/data"
if shared_data_path.is_dir():
return shared_data_path
shared_data_path = pytestconfig.rootpath / "tests/data"
if shared_data_path.is_dir():
return shared_data_path
# Else, raise an exception to avoid running more tests
raise IOError("No shared test data folder found")


@pytest.fixture(name="db_factory", scope="session")
Expand Down
Loading