Tests that importorskip('petab') skip when petab is installed but broken, so a broken petab passes CI as skipped tests

Open
#1,031 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
testing

Research direction

Start by reading tests/conftest.py and the seven tutorial test modules updated for #1028, then locate the remaining pytest.importorskip('petab') calls across the 20 test files. Check that tests skip only when petab is absent and fail when an installed petab raises an import error; use the reproduction in the issue to verify the behavior.

Written by the indexing model from the issue text.

Description

latent bug

153 calls of pytest.importorskip('petab') (or a petab. submodule) in 20 test files skip their tests when petab cannot be imported for any reason. pytest's importorskip turns a ModuleNotFoundError into a skip, and that includes one raised inside petab for a dependency that petab itself is missing. A petab that is installed but broken therefore does not fail any of these tests. They report as skipped, and some skip reasons name the wrong cause.

Reproduction. Put a stand-in petab on the path whose import fails on a missing dependency:

mkdir -p /tmp/fakepetab/petab
echo "import a_dependency_that_is_missing_xyz" > /tmp/fakepetab/petab/__init__.py
PYTHONPATH=/tmp/fakepetab .venv/bin/python -m pytest -o addopts='' -q -rs tests/test_linear_profiling.py tests/test_expression_objective.py

With the real petab 0.9.0 these two modules run 95 tests, all passing. With the broken one, both modules skip as a whole:

SKIPPED [1] tests/test_linear_profiling.py:39: could not import 'petab': No module named 'a_dependency_that_is_missing_xyz'
SKIPPED [1] tests/test_expression_objective.py:32: objective = expression needs the optional pybnf[petab] extra

The second reason says the extra is not installed. It is installed, and broken.

This matters most where petab breaks in an upgrade. petab has no pin beyond >=0.9,<1, and every CI leg except the dependency-floors one installs it, so a petab release that fails to import in PyBNF's environment would turn these suites into skips on every leg, with CI green.

#1028 added a petab marker that tests/conftest.py skips only when petab is absent (importlib.util.find_spec('petab') is None), and module-level skips in seven tutorial test modules that follow the same rule. A petab that is present but broken fails those tests. Converting the remaining importorskip('petab') calls to the marker, or to the same find_spec check, would give every petab test that behaviour.

Dominant language
Python
Stars
25
Forks
25
Avg merge
4h 5m
Merged PRs (30d)
10

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lanl/PyBNF

All issues in lanl/PyBNF

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.