conda install -c conda-forge jupyter_dojo
Cell Magics + Toolbar
pip install ipython_unittest
Apenas cell magics
In [3]:
%load_ext ipython_unittest
In [7]:
def add(x, y):
return x + y
In [8]:
%%unittest
assert add(1, 1) == 2
assert add(1, 2) == 3
assert add(2, 2) == 4
Out[8]:
In [ ]:
In [ ]:
%load_ext ipython_unittest
In [ ]:
def fizzbuzz():
pass
In [ ]:
%%unittest -p 1
assert fizzbuzz() == 0
In [ ]:
In [ ]:
In [ ]:
import unittest
import sys
class JupyterTest(unittest.TestCase):
def test_add_1_1_returns_2(self):
self.assertEqual(add(1, 1), 2)
def test_add_1_2_returns_3(self):
self.assertEqual(add(1, 2), 3)
def test_add_2_2_returns_4(self):
self.assertEqual(add(2, 2), 4)
suite = unittest.TestLoader().loadTestsFromTestCase(JupyterTest)
unittest.TextTestRunner(verbosity=1, stream=sys.stdout).run(suite)
In [ ]:
In [ ]:
!pip install astunparse
In [9]:
%%unittest -u
"add 1 + 1 returns 2"
assert add(1, 1) == 2
"add 1 + 2 returns 3"
assert add(1, 2) == 3
"add 2 + 2 returns 4"
assert add(2, 2) == 4
Out[9]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
%%write javascript test.js
var assert = require('assert');
describe('Array', function() {
describe('#indexOf()', function() {
it('should return -1 when the value is not present', function() {
assert.equal(-1, [1,2,3].indexOf(4));
});
});
});
In [ ]:
%%external --previous 1
mocha test.js
In [ ]:
%%unittest_main
class JupyterTest(unittest.TestCase):
def test_add_1_1_returns_2(self):
self.assertEqual(add(1, 1), 2)
def test_add_1_2_returns_3(self):
self.assertEqual(add(1, 2), 3)
def test_add_2_2_returns_4(self):
self.assertEqual(add(2, 2), 4)
In [ ]:
%%unittest_testcase
def test_add_1_1_returns_2(self):
self.assertEqual(add(1, 1), 2)
def test_add_1_2_returns_3(self):
self.assertEqual(add(1, 2), 3)
def test_add_2_2_returns_4(self):
self.assertEqual(add(2, 2), 4)
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
conda install -c conda-forge jupyter_dojo
Cell Magics + Toolbar
pip install ipython_unittest
Apenas cell magics
In [ ]: