In [15]:
%reload_ext ipython_unittest
In [16]:
def sum(x, y):
return x + y
In [17]:
%%unittest --dojo
assert sum(1, 1) == 2
assert sum(1, 2) == 3
assert sum(2, 2) == 4
Out[17]:
In [ ]:
%%unittest -c
"1 plus 1 equals 2"
assert sum(1, 1) == 2
"1 plus 2 equals 3"
assert sum(1, 2) == 3
"2 plus 2 equals 4"
assert sum(2, 2) == 4
In [ ]:
%%unittest_testcase -t MyTestCase
def test_1_plus_1_equals_2(self):
self.assertEqual(sum(1, 1), 2)
def test_1_plus_2_equals_3(self):
self.assertEqual(sum(1, 2), 3)
def test_2_plus_2_equals_4(self):
self.assertEqual(sum(2, 2), 4)
In [ ]:
%%unittest_main
class MyTestCase(unittest.TestCase):
def test_1_plus_1_equals_2(self):
self.assertEqual(sum(1, 1), 2)
def test_1_plus_2_equals_3(self):
self.assertEqual(sum(1, 2), 3)
def test_2_plus_2_equals_4(self):
self.assertEqual(sum(2, 2), 4)