Skip to content
Open
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
2 changes: 1 addition & 1 deletion treon/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def run_tests(self):
LOG.info("Triggered test for %s", self.file_path)

try:
self.is_successful, console_output = execute_notebook(self.file_path)
self.is_successful, console_output = execute_notebook(self.file_path, _is_verbose())
result = self.result_string()

if not self.is_successful or _is_verbose():
Expand Down
9 changes: 8 additions & 1 deletion treon/test_execution.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import os
import logging
import textwrap
import nbformat

from nbformat.v4 import new_code_cell
from nbconvert.preprocessors import ExecutePreprocessor

LOG = logging.getLogger('treon.task')

def execute_notebook(path):
def execute_notebook(path, verbose=False):
notebook = nbformat.read(path, as_version=4)
notebook.cells.extend([unittest_cell(), doctest_cell()])
processor = ExecutePreprocessor(timeout=-1, kernel_name='python3')

if verbose:
def print_executed_cell_index(cell, cell_index):
LOG.debug(f"Start executing cell {cell_index}")
processor.on_cell_start = print_executed_cell_index
processor.preprocess(notebook, metadata(path))
return parse_test_result(notebook.cells)

Expand Down