Skip to content

Commit

Permalink
Compatibility with 'pkg test' (closes #4)
Browse files Browse the repository at this point in the history
  • Loading branch information
siko1056 committed Nov 23, 2021
1 parent baf41be commit ddb903e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 17 additions & 4 deletions src/jupyter_notebook.m
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,19 @@ function addErrorOutput (obj, cell_index, error_msg)

endclassdef

%!shared example_dir
%! ## development path
%! example_dir = fullfile ("..", "doc", "examples");
%! if (exist (fullfile (example_dir, "octave_kernel.ipynb"), "file") != 2)
%! ## installed package path
%! if (isempty (pkg ("list", "jupyter-notebook")))
%! error ("jupyter_notebook: cannot detect example directory");
%! else
%! example_dir = pkg ("list", "jupyter-notebook"){1}.dir;
%! example_dir = fullfile (example_dir, "doc", "examples");
%! endif
%! endif
%! assert (exist (fullfile (example_dir, "octave_kernel.ipynb"), "file"), 2);

## Test running a single cell
%!test
Expand All @@ -721,7 +734,7 @@ function addErrorOutput (obj, cell_index, error_msg)
%! endif
%! set (0, "defaultfigurevisible", "off");
%!
%! n = jupyter_notebook (fullfile ("..", "examples", "octave_kernel.ipynb"));
%! n = jupyter_notebook (fullfile (example_dir, "octave_kernel.ipynb"));
%!
%! ## Test embedding images
%! n.run (2);
Expand Down Expand Up @@ -756,7 +769,7 @@ function addErrorOutput (obj, cell_index, error_msg)
%! endif
%! set (0, "defaultfigurevisible", "off");
%!
%! n = jupyter_notebook (fullfile ("..", "examples", "octave_kernel.ipynb"));
%! n = jupyter_notebook (fullfile (example_dir, "octave_kernel.ipynb"));
%! n.run_all ();
%!
%! ## Test embedding images
Expand Down Expand Up @@ -795,7 +808,7 @@ function addErrorOutput (obj, cell_index, error_msg)
%! endif
%! set (0, "defaultfigurevisible", "off");
%!
%! n = jupyter_notebook (fullfile ("..", "examples",
%! n = jupyter_notebook (fullfile (example_dir, ...
%! "plot_magic_and_errors.ipynb"));
%!
%! ## PNG format
Expand Down Expand Up @@ -840,7 +853,7 @@ function addErrorOutput (obj, cell_index, error_msg)
%! endif
%! set (0, "defaultfigurevisible", "off");
%!
%! n = jupyter_notebook (fullfile ("..", "examples",
%! n = jupyter_notebook (fullfile (example_dir, ...
%! "plot_magic_and_errors.ipynb"));
%!
%! ## Wrong resolution
Expand Down

0 comments on commit ddb903e

Please sign in to comment.