Skip to content
Open
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
17 changes: 15 additions & 2 deletions src/nbmake/pytest_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pygments.lexers import Python3TracebackLexer

from .nb_result import NotebookError, NotebookResult
from .nb_run import NotebookRun
from .nb_run import NB_VERSION, NotebookRun


class NbMakeFailureRepr(TerminalRepr):
Expand All @@ -26,7 +26,20 @@ def toterminal(self, tw: TerminalWriter) -> None:

class NotebookFile(pytest.File):
def collect(self) -> Generator[Any, Any, Any]:
yield NotebookItem.from_parent(self, filename=str(Path(self.fspath)))
item = NotebookItem.from_parent(self, filename=str(Path(self.fspath)))

with open(self.fspath, "rb") as fp:
nb = nbformat.read(fp, NB_VERSION)

markers = nb.metadata.get("execution", {}).get("nbmake", {}).get("markers", [])

if isinstance(markers, str):
markers = [marker.strip() for marker in markers.split(",")]

for marker in markers:
item.add_marker(marker)

yield item


class NotebookFailedException(Exception):
Expand Down
Loading