{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# nosebook\n",
    "\n",
    "a [nose](http://nose.readthedocs.org/) plugin for finding and running IPython 3 notebooks as nose tests.\n",
    "\n",
    "You can use it to decrease the burden of documentation and testing by making a single set of notebooks into both rich documentation and a part of your test suite, with certain limitations.\n",
    "\n",
    "\n",
    "[![Build Status][svg]][status]\n",
    "\n",
    "[svg]: https://travis-ci.org/bollwyvl/nosebook.svg?branch=master\n",
    "[status]: https://travis-ci.org/bollwyvl/nosebook"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## How does it work?\n",
    "Each notebook 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.\n",
    "\n",
    "Each `code` will be executed against the kernel in the order they appear in the notebook: other cells e.g. `markdown`, `raw`, are just ignored.\n",
    "\n",
    "The output has to __match exactly__, with the following parts of the output stripped:\n",
    "\n",
    "- execution numbers, i.e. `[1]:`\n",
    "- tracebacks\n",
    "\n",
    "This can be a problem, such as with class `_repr_` methods that include the memory location of the instance, so care should be taken with non-deterministic output."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Configuring `nosetests` to use `nosebook`\n",
    "These options can be specified in your [nose config file](./.noserc), or as long-form command line arguments, i.e. `--with-nosebook`."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### `with-nosebook`\n",
    "`nosetests` will look for notebooks that seem like tests, as configured with [`nosebook-match`](#nosebook-match). \n",
    "\n",
    "_Default: False_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Basic usage\n",
    "!nosetests --with-nosebook"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### `nosebook-match`\n",
    "A regular expression that tells nosebook what should be a testable notebook.\n",
    "\n",
    "_Default: `.*[Tt]est.*.ipynb$`_\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Run against all notebooks... probably not a good idea\n",
    "!nosetests --with-nosebook --nosebook-match .*.ipynb"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## `python setup.py test` integration\n",
    "Strangely complex, see the example in [`setup.py`](./setup.py)."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.4.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
