Skip to content

Commit 8b3b701

Browse files
authored
Fix non-ignored test, check all tests are executed (#4262)
* put test_distributions in separate job * 🎨 sort * add arviz compat job * fix ignored test * document * document * noop
1 parent a6295a3 commit 8b3b701

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

.github/workflows/pytest.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ jobs:
2121
--ignore=pymc3/tests/test_distributions_timeseries.py
2222
--ignore=pymc3/tests/test_examples.py
2323
--ignore=pymc3/tests/test_gp.py
24+
--ignore=pymc3/tests/test_mixture.py
2425
--ignore=pymc3/tests/test_parallel_sampling.py
2526
--ignore=pymc3/tests/test_posteriors.py
2627
--ignore=pymc3/tests/test_quadpotential.py
2728
--ignore=pymc3/tests/test_random.py
2829
--ignore=pymc3/tests/test_sampling.py
29-
--ignore=pymc3/tests/test_shape_handling
30+
--ignore=pymc3/tests/test_shape_handling.py
3031
--ignore=pymc3/tests/test_shared.py
3132
--ignore=pymc3/tests/test_smc.py
3233
--ignore=pymc3/tests/test_updates.py
@@ -44,6 +45,7 @@ jobs:
4445
- |
4546
pymc3/tests/test_examples.py
4647
pymc3/tests/test_gp.py
48+
pymc3/tests/test_mixture.py
4749
pymc3/tests/test_posteriors.py
4850
pymc3/tests/test_quadpotential.py
4951
- |

.pre-commit-config.yaml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,21 @@ repos:
3131
- repo: local
3232
hooks:
3333
- id: watermark
34-
name: Check notebooks have watermark (see Jupyter style guide from PyMC3 Wiki)
35-
types: [jupyter]
34+
args: [--negate, --multiline]
3635
entry: '%load_ext watermark.*%watermark -n -u -v -iv -w'
3736
language: pygrep
38-
args: [--negate, --multiline]
3937
minimum_pre_commit_version: 2.8.0
38+
name: Check notebooks have watermark (see Jupyter style guide from PyMC3 Wiki)
39+
types: [jupyter]
4040
- id: check-toc
41+
entry: python scripts/check_toc_is_complete.py
42+
language: python
4143
name: Check all notebooks appear in table of contents
44+
pass_filenames: false
4245
types: [jupyter]
43-
entry: python scripts/check_toc_is_complete.py
46+
- id: check-no-tests-are-ignored
47+
entry: python scripts/check_all_tests_are_covered.py
48+
files: ^\.github/workflows/pytest\.yml$
4449
language: python
50+
name: Check no tests are ignored
51+
pass_filenames: false
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""
2+
In .github/workflows/pytest.yml, tests are split between multiple jobs.
3+
4+
Here, we check that the jobs ignored by the first job actually end up getting
5+
run by the other jobs.
6+
This is intended to be used as a pre-commit hook, see `.pre-commit-config.yaml`.
7+
You can run it manually with `pre-commit run check-no-tests-are-ignored --all`.
8+
"""
9+
10+
from pathlib import Path
11+
12+
import re
13+
14+
if __name__ == "__main__":
15+
pytest_ci_job = Path(".github") / "workflows/pytest.yml"
16+
txt = pytest_ci_job.read_text()
17+
ignored_tests = set(re.findall(r"(?<=--ignore=)(pymc3/tests.*\.py)", txt))
18+
non_ignored_tests = set(re.findall(r"(?<!--ignore=)(pymc3/tests.*\.py)", txt))
19+
assert (
20+
ignored_tests <= non_ignored_tests
21+
), f"The following tests are ignored by the first job but not run by the others: {ignored_tests.difference(non_ignored_tests)}"
22+
assert (
23+
ignored_tests >= non_ignored_tests
24+
), f"The following tests are run by multiple jobs: {non_ignored_tests.difference(ignored_tests)}"

0 commit comments

Comments
 (0)