• Stars
    star
    79
  • Rank 394,724 (Top 9 %)
  • Language
    Jupyter Notebook
  • License
    BSD 3-Clause "New...
  • Created about 9 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a nose plugin for finding and running IPython notebooks as nose tests

nosebook

Build Status PyPI BSD

a nose plugin for finding and running IPython 2/3 notebooks as nose tests.

What it can't do in terms of setup and tearDown, nosebook makes up for in simplicity: there is no %%nose magic, no metadata required: the notebook on disk is the "gold master".

This makes it ideal for decreasing the burden of keeping documentation up to date with tests by making a single set of notebooks into both rich, multi-format documentation and a simple part of your test suite.

How does it work?

Each notebook found according to `nosebook-match <#nosebook-match>`__ is started with a fresh kernel, based on the kernel specified in the notebook. If the kernel is not installed, no tests will be run and the error will be logged.

Each code cell that matches `nosebook-match-cell <#nosebook-match-cell>__ will be executed against the kernel in the order in which it appears in the notebook: other cells e.g. markdown, raw`, are ignored.

The number and content of outputs has to match exactly, with the following parts of each output stripped:

  • execution/prompt numbers, i.e. [1]:
  • tracebacks

Non-deterministic output, such as with _repr_ methods that include the memory location of the instance, will obviously not match every time. You can use `nosebook-scrub <#nosebook-scrub>`__ to rewrite or remove offending content.

  • `ipython_nose <http://github.com/taavi/ipython_nose>__ allows you to use a notebook as a nose runner, with traditional test_whatever methods. You can sort of emulate this behavior with nosebook-match-cell <#nosebook-match-cel>`__... as long as you check in passing tests!

Configuring nosetests to use nosebook

These options can be specified in your nose config file, or as long-form command line arguments, i.e. --with-nosebook.

with-nosebook

nosetests will look for notebooks that seem like tests, as configured with `nosebook-match <#nosebook-match>`__.

Default: False

# Basic usage
!nosetests --with-nosebook

nosebook-match

A regular expression that tells nosebook what should be a testable notebook.

Default: ``.[Tt]est..ipynb$``

# Run against all notebooks... probably not a good idea, but maybe a great idea
!nosetests --with-nosebook --nosebook-match .*.ipynb

nosebook-match-cell

A regular expression that will be replaced throughout the expected outputs and generated outputs.

Default: None

# will run cells where tests are defined... but you should probably run them, too
!nosetests --with-nosebook --nosebook-match .*Simple.* --nosebook-match-cell '(def|class).*[Tt]est'

nosebook-scrub

A regular expression that will be replaced throughout the expected outputs and generated outputs.

Default: None

# you can't fail if you don't try
!nosetests --with-nosebook --nosebook-scrub .+

For multiple scrub values, you can pass a JSON-formatted list of regular expressions or object of pattern-replacement pairs that will be replaced. When passed in via the command line, you'll have to escape special characters: using a .noserc config file makes this easier.

# there are only 10 kinds of tests...
!nosetests --with-nosebook --nosebook-scrub='["0", "1"]'
# 0 is equally good
!nosetests --with-nosebook --nosebook-scrub='{"\\d+": "0"}'

Contributing

Issues and pull requests welcome!

License

nosebook is released as free software under the BSD 3-Clause license.

More Repositories

1

hy_kernel

A simple IPython kernel for Hy
Jupyter Notebook
46
star
2

blockd3

d3 for the Blockly visual programming language
JavaScript
45
star
3

nb-mermaid

DEPRECATED Mermaid diagrams in the Jupyter Notebook
Jupyter Notebook
36
star
4

TangleDown

Markdown + Tangle.js + (someday) SymPy
JavaScript
30
star
5

ipytangle

Build Tangle-style interactive documents in the Jupyter/IPython Notebook
JavaScript
12
star
6

nbdiffstream

proof-of-concept visual diff for jupyter notebooks
HTML
8
star
7

yamlmagic

A magic for making YAML in the IPython notebook
Python
8
star
8

ip-bootstrap

More Twitter Bootstrap Widgets for the IPython Notebook
JavaScript
7
star
9

es6-promise-debounce

Debounce ES6 Promises
JavaScript
6
star
10

fragile

fra.gl is a browser-based app for visualizing the relationships between the community artifacts of open source project such as repos, issues, pull requests and collaborators.
JavaScript
5
star
11

b4

b4: beautiful blockly block builder
JavaScript
4
star
12

jademagic

Write HTML sanely in the IPython notebook with Jade (ne Pug)
Python
4
star
13

Blockly

unofficial mirror of code.google.com/p/blockly for blockd3 and b4
JavaScript
4
star
14

ipython-notebook-navigator

This is a standalone navigation enhancement for the IPython (>1.0) HTML Notebook.
JavaScript
3
star
15

jupyterlab-outsource

Edit (code, prose) with things other than code
TypeScript
3
star
16

flask-reloaded

A kinda ghetto way to reload your Flask pages when *any* file (templates, css, js, etc) is changed. Useful for rapid prototyping, probably __totally unsafe in production__.
Python
3
star
17

ipy-watchdog-widget

An IPython/Jupyter widget that watches local files
Python
2
star
18

d3-derby-behaviors

A sample application showing pan/zoom/drag with derby and d3
JavaScript
2
star
19

sympy-latex-hypothesis

Jupyter Notebook
2
star
20

ipylivecoder

Live coding JavaScript against IPython widget data
JavaScript
2
star
21

ip-cad

A CAD file viewer widget for the IPython Notebook
JavaScript
2
star
22

dangerous-playgrounds

Building playground applications in the Jupyter Notebook with widgets
Jupyter Notebook
2
star
23

ose-it-proposal

Proposal: IT Roadmap for http://opensourceecology.org
2
star
24

wallpaperator

Serverless HTML5 Wallpaper/Screensaver Generator for E-Readers, Smartphones, etc.
JavaScript
2
star
25

nb-wysiwyg

a wysiwyg preview/editor for markdown in the ipython/jupyter notebook
JavaScript
2
star
26

discaddy

Open Source Disc Golf Scorecard and Handicapping application
2
star
27

quarto

literate jupyter, with an emphasis on simplicity
HTML
1
star
28

visicons

nice icons for data visualization
HTML
1
star
29

smultiple

a mildly-opinionated reusable small multiple layout for d3
JavaScript
1
star
30

nb-livereload

✨Autoreload static files in the Jupyter Notebook
Python
1
star
31

firacode-webfont

HTML
1
star
32

nbviewer-gitlab

[WIP] A strawman nbviewer provider implementation for gitlab
Python
1
star
33

cadlab

Experiments in building installers for JupyterLab, CAD Framework and Friends
RobotFramework
1
star
34

k3

a fluent API for kiwi.js constraints
JavaScript
1
star