diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 000000000..505631475 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,11 @@ +import pytest + +LAST = "test_last.py" + + +def pytest_collection_modifyitems( + items: list[pytest.Function], +) -> list[pytest.Function]: + return [i for i in items if i.module.__name__ != LAST] + [ + i for i in items if i.module.__name__ == LAST + ] diff --git a/tests/test_last.py b/tests/test_last.py new file mode 100644 index 000000000..040a7c40a --- /dev/null +++ b/tests/test_last.py @@ -0,0 +1,6 @@ +from tests.utils_for_testbook import TESTED_NOTEBOOKS +from tests.utils_for_tests import iterate_notebook_names + + +def test_are_all_notebooks_tested(): + assert sorted(TESTED_NOTEBOOKS) == sorted(iterate_notebook_names()) diff --git a/tests/utils_for_testbook.py b/tests/utils_for_testbook.py index 1bf25fc79..510d22387 100644 --- a/tests/utils_for_testbook.py +++ b/tests/utils_for_testbook.py @@ -18,6 +18,8 @@ _PATCHED = False +TESTED_NOTEBOOKS: list[str] = [] + def wrap_testbook(notebook_name: str, timeout_seconds: float = 10) -> Callable: def inner_decorator(func: Callable) -> Any: @@ -26,6 +28,7 @@ def inner_decorator(func: Callable) -> Any: notebook_path = resolve_notebook_path(notebook_name) for decorator in [ + _build_mark_as_tested(notebook_name), testbook(notebook_path, execute=True, timeout=timeout_seconds), _build_cd_decorator(notebook_path), _build_skip_decorator(notebook_path), @@ -62,6 +65,19 @@ def _build_skip_decorator(notebook_path: str) -> Callable: ) +def _build_mark_as_tested(notebook_name: str) -> Callable: + def mark_as_tested_decorator(func: Callable) -> Any: + def inner(*args: Any, **kwargs: Any) -> Any: + try: + func(*args, **kwargs) + finally: + TESTED_NOTEBOOKS.append(notebook_name) + + return inner + + return mark_as_tested_decorator + + def _patch_testbook() -> None: global _PATCHED