Documentation ¶
Overview ¶
Package nbtests holds tools to run functional tests for GoNB using `nbconvert`.
The actual tests are instrumented in `nbtests_test.go`, but this package exports several tools that would allow one to instrument tests for their own notebooks elsewhere, if for some reason it is handy.
Index ¶
Constants ¶
const Separator = "----" // String used as separator by `nbconvert` in text mode.
Variables ¶
This section is empty.
Functions ¶
func Check ¶
Check that the input given in reader matches the `want` expectation. Returns nil is expectation was matched, or an error with the failed match description.
If `print` is set, it also prints the lines read from `r`.
func GoNBRootDir ¶
func GoNBRootDir() string
func InputLine ¶
InputLine returns the line that precedes the cell input as written by `nbconvert -to asciidoc`. This is a convenience to add to the testing of notebooks.
func InstallTmpGonbKernel ¶
InstallTmpGonbKernel will create a temporary directory, set the environment variable JUPYTER_DATA_DIR to that directory, and compile and install GoNB to that directory, so it will be used by `nbconvert`.
It also compiles `nbexec` to the same directory, which is used to controle the execution of the notebooks.
Parameters:
- `gonbRunArgs` are passed to `go run --cover <gonbRunArgs> .` command, executed from GoNB's root directory.
- `extraInstallArgs` are passed to the `gonb --install` execution. Typical values here include `--logtostderr`, and `--vmodule=...` for verbose output.
Notice that this precludes concurrent testing of various versions of GoNB in the same process, since it relies on this one global environment variable (JUPYTER_DATA_DIR) -- but one can still run different processes concurrently.
func OutputLine ¶
OutputLine returns the line that precedes the output of a cell generated by `nbconvert -to asciidoc`. This is a convenience to add to the testing of notebooks.
Types ¶
type ExpectFn ¶
ExpectFn is a function that checks for expectations of an input line. It should return true, if the expectation was matched, false if not yet, or return an error if there was something wrong with the line and it the testing should fail immediately.
When the input is finished, ExpectFn is called with `eof=true`, in which case it should either return true or an error.
See the following functions that return `ExpectFn` that can be used:
Match() Sequence()
func Capture ¶
Capture accepts the next line and stores its value in the `capturedLine` variable. This can be used for later processing.