Skip to content

Instantly share code, notes, and snippets.

@stefanv
Created November 1, 2012 21:09
Show Gist options
  • Select an option

  • Save stefanv/3996557 to your computer and use it in GitHub Desktop.

Select an option

Save stefanv/3996557 to your computer and use it in GitHub Desktop.
Executing Nose in the notebook
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": "nose"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"def add(a, b):\n",
" return a + b"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 11
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import nose\n",
"from nose.tools import assert_equal\n",
"import unittest\n",
"\n",
"class TestAll(unittest.TestCase):\n",
"\n",
" def test_basic(self):\n",
" assert_equal(add(1, 1), 2)\n",
"\n",
" def test_zero_sum(self):\n",
" assert_equal(add(3, -3), 0)"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 12
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"suite = nose.loader.TestLoader().loadTestsFromTestCase(TestAll)\n",
"nose.run(suite=suite, argv=['', '-v'])"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stderr",
"text": [
"test_basic (__main__.TestAll) ... "
]
},
{
"output_type": "stream",
"stream": "stderr",
"text": [
"ok\n",
"test_zero_sum (__main__.TestAll) ... "
]
},
{
"output_type": "stream",
"stream": "stderr",
"text": [
"ok\n",
"\n",
"----------------------------------------------------------------------\n",
"Ran 2 tests in 0.005s\n",
"\n",
"OK\n"
]
},
{
"output_type": "pyout",
"prompt_number": 13,
"text": [
"True"
]
}
],
"prompt_number": 13
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment