Skip to content
Closed
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
11 changes: 11 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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
]
6 changes: 6 additions & 0 deletions tests/test_last.py
Original file line number Diff line number Diff line change
@@ -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())
16 changes: 16 additions & 0 deletions tests/utils_for_testbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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),
Expand Down Expand Up @@ -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

Expand Down