#273: Remove nose dependency for math_probability/ (#281)

This commit is contained in:
Donne Martin 2020-07-14 21:23:57 -04:00 committed by GitHub
parent 76cb6507fc
commit 67505c49b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 212 additions and 280 deletions

View File

@ -76,9 +76,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class Solution(object):\n",
@ -105,24 +103,22 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"# %load test_add_digits.py\n",
"from nose.tools import assert_equal, assert_raises\n",
"import unittest\n",
"\n",
"\n",
"class TestAddDigits(object):\n",
"class TestAddDigits(unittest.TestCase):\n",
"\n",
" def test_add_digits(self, func):\n",
" assert_raises(TypeError, func, None)\n",
" assert_raises(ValueError, func, -1)\n",
" assert_equal(func(0), 0)\n",
" assert_equal(func(9), 9)\n",
" assert_equal(func(138), 3)\n",
" assert_equal(func(65536), 7) \n",
" self.assertRaises(TypeError, func, None)\n",
" self.assertRaises(ValueError, func, -1)\n",
" self.assertEqual(func(0), 0)\n",
" self.assertEqual(func(9), 9)\n",
" self.assertEqual(func(138), 3)\n",
" self.assertEqual(func(65536), 7) \n",
" print('Success: test_add_digits')\n",
"\n",
"\n",
@ -168,9 +164,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.0"
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}

View File

@ -89,9 +89,7 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class Solution(object):\n",
@ -134,9 +132,7 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@ -148,18 +144,18 @@
],
"source": [
"%%writefile test_add_digits.py\n",
"from nose.tools import assert_equal, assert_raises\n",
"import unittest\n",
"\n",
"\n",
"class TestAddDigits(object):\n",
"class TestAddDigits(unittest.TestCase):\n",
"\n",
" def test_add_digits(self, func):\n",
" assert_raises(TypeError, func, None)\n",
" assert_raises(ValueError, func, -1)\n",
" assert_equal(func(0), 0)\n",
" assert_equal(func(9), 9)\n",
" assert_equal(func(138), 3)\n",
" assert_equal(func(65536), 7) \n",
" self.assertRaises(TypeError, func, None)\n",
" self.assertRaises(ValueError, func, -1)\n",
" self.assertEqual(func(0), 0)\n",
" self.assertEqual(func(9), 9)\n",
" self.assertEqual(func(138), 3)\n",
" self.assertEqual(func(65536), 7) \n",
" print('Success: test_add_digits')\n",
"\n",
"\n",
@ -182,9 +178,7 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@ -216,9 +210,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.3"
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}

View File

@ -1,15 +1,15 @@
from nose.tools import assert_equal, assert_raises
import unittest
class TestAddDigits(object):
class TestAddDigits(unittest.TestCase):
def test_add_digits(self, func):
assert_raises(TypeError, func, None)
assert_raises(ValueError, func, -1)
assert_equal(func(0), 0)
assert_equal(func(9), 9)
assert_equal(func(138), 3)
assert_equal(func(65536), 7)
self.assertRaises(TypeError, func, None)
self.assertRaises(ValueError, func, -1)
self.assertEqual(func(0), 0)
self.assertEqual(func(9), 9)
self.assertEqual(func(138), 3)
self.assertEqual(func(65536), 7)
print('Success: test_add_digits')

View File

@ -73,9 +73,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class Math(object):\n",
@ -102,24 +100,22 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"# %load test_check_prime.py\n",
"from nose.tools import assert_equal, assert_raises\n",
"import unittest\n",
"\n",
"\n",
"class TestMath(object):\n",
"class TestMath(unittest.TestCase):\n",
"\n",
" def test_check_prime(self):\n",
" math = Math()\n",
" assert_raises(TypeError, math.check_prime, None)\n",
" assert_raises(TypeError, math.check_prime, 98.6)\n",
" assert_equal(math.check_prime(0), False)\n",
" assert_equal(math.check_prime(1), False)\n",
" assert_equal(math.check_prime(97), True)\n",
" self.assertRaises(TypeError, math.check_prime, None)\n",
" self.assertRaises(TypeError, math.check_prime, 98.6)\n",
" self.assertEqual(math.check_prime(0), False)\n",
" self.assertEqual(math.check_prime(1), False)\n",
" self.assertEqual(math.check_prime(97), True)\n",
" print('Success: test_check_prime')\n",
"\n",
"\n",
@ -158,9 +154,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.0"
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}

View File

@ -84,9 +84,7 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"import math\n",
@ -125,9 +123,7 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@ -139,18 +135,18 @@
],
"source": [
"%%writefile test_check_prime.py\n",
"from nose.tools import assert_equal, assert_raises\n",
"import unittest\n",
"\n",
"\n",
"class TestMath(object):\n",
"class TestMath(unittest.TestCase):\n",
"\n",
" def test_check_prime(self):\n",
" math = Math()\n",
" assert_raises(TypeError, math.check_prime, None)\n",
" assert_raises(TypeError, math.check_prime, 98.6)\n",
" assert_equal(math.check_prime(0), False)\n",
" assert_equal(math.check_prime(1), False)\n",
" assert_equal(math.check_prime(97), True)\n",
" self.assertRaises(TypeError, math.check_prime, None)\n",
" self.assertRaises(TypeError, math.check_prime, 98.6)\n",
" self.assertEqual(math.check_prime(0), False)\n",
" self.assertEqual(math.check_prime(1), False)\n",
" self.assertEqual(math.check_prime(97), True)\n",
" print('Success: test_check_prime')\n",
"\n",
"\n",
@ -166,9 +162,7 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@ -199,9 +193,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.0"
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}

View File

@ -1,15 +1,15 @@
from nose.tools import assert_equal, assert_raises
import unittest
class TestMath(object):
class TestMath(unittest.TestCase):
def test_check_prime(self):
math = Math()
assert_raises(TypeError, math.check_prime, None)
assert_raises(TypeError, math.check_prime, 98.6)
assert_equal(math.check_prime(0), False)
assert_equal(math.check_prime(1), False)
assert_equal(math.check_prime(97), True)
self.assertRaises(TypeError, math.check_prime, None)
self.assertRaises(TypeError, math.check_prime, 98.6)
self.assertEqual(math.check_prime(0), False)
self.assertEqual(math.check_prime(1), False)
self.assertEqual(math.check_prime(97), True)
print('Success: test_check_prime')

View File

@ -72,9 +72,7 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class PrimeGenerator(object):\n",
@ -101,22 +99,20 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"# %load test_generate_primes.py\n",
"from nose.tools import assert_equal, assert_raises\n",
"import unittest\n",
"\n",
"\n",
"class TestMath(object):\n",
"class TestMath(unittest.TestCase):\n",
"\n",
" def test_generate_primes(self):\n",
" prime_generator = PrimeGenerator()\n",
" assert_raises(TypeError, prime_generator.generate_primes, None)\n",
" assert_raises(TypeError, prime_generator.generate_primes, 98.6)\n",
" assert_equal(prime_generator.generate_primes(20), [False, False, True, \n",
" self.assertRaises(TypeError, prime_generator.generate_primes, None)\n",
" self.assertRaises(TypeError, prime_generator.generate_primes, 98.6)\n",
" self.assertEqual(prime_generator.generate_primes(20), [False, False, True, \n",
" True, False, True, \n",
" False, True, False, \n",
" False, False, True, \n",
@ -161,9 +157,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.0"
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}

View File

@ -88,9 +88,7 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"import math\n",
@ -134,9 +132,7 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@ -148,16 +144,16 @@
],
"source": [
"%%writefile test_generate_primes.py\n",
"from nose.tools import assert_equal, assert_raises\n",
"import unittest\n",
"\n",
"\n",
"class TestMath(object):\n",
"class TestMath(unittest.TestCase):\n",
"\n",
" def test_generate_primes(self):\n",
" prime_generator = PrimeGenerator()\n",
" assert_raises(TypeError, prime_generator.generate_primes, None)\n",
" assert_raises(TypeError, prime_generator.generate_primes, 98.6)\n",
" assert_equal(prime_generator.generate_primes(20), [False, False, True, \n",
" self.assertRaises(TypeError, prime_generator.generate_primes, None)\n",
" self.assertRaises(TypeError, prime_generator.generate_primes, 98.6)\n",
" self.assertEqual(prime_generator.generate_primes(20), [False, False, True, \n",
" True, False, True, \n",
" False, True, False, \n",
" False, False, True, \n",
@ -179,9 +175,7 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@ -212,9 +206,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.0"
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}

View File

@ -1,13 +1,13 @@
from nose.tools import assert_equal, assert_raises
import unittest
class TestMath(object):
class TestMath(unittest.TestCase):
def test_generate_primes(self):
prime_generator = PrimeGenerator()
assert_raises(TypeError, prime_generator.generate_primes, None)
assert_raises(TypeError, prime_generator.generate_primes, 98.6)
assert_equal(prime_generator.generate_primes(20), [False, False, True,
self.assertRaises(TypeError, prime_generator.generate_primes, None)
self.assertRaises(TypeError, prime_generator.generate_primes, 98.6)
self.assertEqual(prime_generator.generate_primes(20), [False, False, True,
True, False, True,
False, True, False,
False, False, True,

View File

@ -82,9 +82,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class Solution(object):\n",
@ -115,20 +113,18 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"# %load test_math_ops.py\n",
"from nose.tools import assert_equal, assert_true, assert_raises\n",
"import unittest\n",
"\n",
"\n",
"class TestMathOps(object):\n",
"class TestMathOps(unittest.TestCase):\n",
"\n",
" def test_math_ops(self):\n",
" solution = Solution()\n",
" assert_raises(TypeError, solution.insert, None)\n",
" self.assertRaises(TypeError, solution.insert, None)\n",
" solution.insert(5)\n",
" solution.insert(2)\n",
" solution.insert(7)\n",
@ -140,10 +136,10 @@
" solution.insert(3)\n",
" solution.insert(3)\n",
" solution.insert(2)\n",
" assert_equal(solution.max, 9)\n",
" assert_equal(solution.min, 2)\n",
" assert_equal(solution.mean, 5)\n",
" assert_true(solution.mode in (2, 9))\n",
" self.assertEqual(solution.max, 9)\n",
" self.assertEqual(solution.min, 2)\n",
" self.assertEqual(solution.mean, 5)\n",
" self.assertTrue(solution.mode in (2, 9))\n",
" print('Success: test_math_ops')\n",
"\n",
"\n",
@ -182,9 +178,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.0"
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}

View File

@ -93,9 +93,7 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"from __future__ import division\n",
@ -143,9 +141,7 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@ -157,14 +153,14 @@
],
"source": [
"%%writefile test_math_ops.py\n",
"from nose.tools import assert_equal, assert_true, assert_raises\n",
"import unittest\n",
"\n",
"\n",
"class TestMathOps(object):\n",
"class TestMathOps(unittest.TestCase):\n",
"\n",
" def test_math_ops(self):\n",
" solution = Solution()\n",
" assert_raises(TypeError, solution.insert, None)\n",
" self.assertRaises(TypeError, solution.insert, None)\n",
" solution.insert(5)\n",
" solution.insert(2)\n",
" solution.insert(7)\n",
@ -176,10 +172,10 @@
" solution.insert(3)\n",
" solution.insert(3)\n",
" solution.insert(2)\n",
" assert_equal(solution.max, 9)\n",
" assert_equal(solution.min, 2)\n",
" assert_equal(solution.mean, 5)\n",
" assert_true(solution.mode in (2, 9))\n",
" self.assertEqual(solution.max, 9)\n",
" self.assertEqual(solution.min, 2)\n",
" self.assertEqual(solution.mean, 5)\n",
" self.assertTrue(solution.mode in (2, 9))\n",
" print('Success: test_math_ops')\n",
"\n",
"\n",
@ -195,9 +191,7 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@ -228,9 +222,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.0"
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}

View File

@ -1,11 +1,11 @@
from nose.tools import assert_equal, assert_true, assert_raises
import unittest
class TestMathOps(object):
class TestMathOps(unittest.TestCase):
def test_math_ops(self):
solution = Solution()
assert_raises(TypeError, solution.insert, None)
self.assertRaises(TypeError, solution.insert, None)
solution.insert(5)
solution.insert(2)
solution.insert(7)
@ -17,10 +17,10 @@ class TestMathOps(object):
solution.insert(3)
solution.insert(3)
solution.insert(2)
assert_equal(solution.max, 9)
assert_equal(solution.min, 2)
assert_equal(solution.mean, 5)
assert_true(solution.mode in (2, 9))
self.assertEqual(solution.max, 9)
self.assertEqual(solution.min, 2)
self.assertEqual(solution.mean, 5)
self.assertTrue(solution.mode in (2, 9))
print('Success: test_math_ops')

View File

@ -77,9 +77,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class Solution(object):\n",
@ -106,25 +104,23 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"# %load test_is_power_of_two.py\n",
"from nose.tools import assert_equal, assert_raises\n",
"import unittest\n",
"\n",
"\n",
"class TestSolution(object):\n",
"class TestSolution(unittest.TestCase):\n",
"\n",
" def test_is_power_of_two(self):\n",
" solution = Solution()\n",
" assert_raises(TypeError, solution.is_power_of_two, None)\n",
" assert_equal(solution.is_power_of_two(0), False)\n",
" assert_equal(solution.is_power_of_two(1), True)\n",
" assert_equal(solution.is_power_of_two(2), True)\n",
" assert_equal(solution.is_power_of_two(15), False)\n",
" assert_equal(solution.is_power_of_two(16), True)\n",
" self.assertRaises(TypeError, solution.is_power_of_two, None)\n",
" self.assertEqual(solution.is_power_of_two(0), False)\n",
" self.assertEqual(solution.is_power_of_two(1), True)\n",
" self.assertEqual(solution.is_power_of_two(2), True)\n",
" self.assertEqual(solution.is_power_of_two(15), False)\n",
" self.assertEqual(solution.is_power_of_two(16), True)\n",
" print('Success: test_is_power_of_two')\n",
"\n",
"\n",
@ -163,9 +159,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.0"
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}

View File

@ -98,9 +98,7 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class Solution(object):\n",
@ -123,9 +121,7 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@ -137,19 +133,19 @@
],
"source": [
"%%writefile test_is_power_of_two.py\n",
"from nose.tools import assert_equal, assert_raises\n",
"import unittest\n",
"\n",
"\n",
"class TestSolution(object):\n",
"class TestSolution(unittest.TestCase):\n",
"\n",
" def test_is_power_of_two(self):\n",
" solution = Solution()\n",
" assert_raises(TypeError, solution.is_power_of_two, None)\n",
" assert_equal(solution.is_power_of_two(0), False)\n",
" assert_equal(solution.is_power_of_two(1), True)\n",
" assert_equal(solution.is_power_of_two(2), True)\n",
" assert_equal(solution.is_power_of_two(15), False)\n",
" assert_equal(solution.is_power_of_two(16), True)\n",
" self.assertRaises(TypeError, solution.is_power_of_two, None)\n",
" self.assertEqual(solution.is_power_of_two(0), False)\n",
" self.assertEqual(solution.is_power_of_two(1), True)\n",
" self.assertEqual(solution.is_power_of_two(2), True)\n",
" self.assertEqual(solution.is_power_of_two(15), False)\n",
" self.assertEqual(solution.is_power_of_two(16), True)\n",
" print('Success: test_is_power_of_two')\n",
"\n",
"\n",
@ -165,9 +161,7 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@ -198,9 +192,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.0"
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}

View File

@ -1,16 +1,16 @@
from nose.tools import assert_equal, assert_raises
import unittest
class TestSolution(object):
class TestSolution(unittest.TestCase):
def test_is_power_of_two(self):
solution = Solution()
assert_raises(TypeError, solution.is_power_of_two, None)
assert_equal(solution.is_power_of_two(0), False)
assert_equal(solution.is_power_of_two(1), True)
assert_equal(solution.is_power_of_two(2), True)
assert_equal(solution.is_power_of_two(15), False)
assert_equal(solution.is_power_of_two(16), True)
self.assertRaises(TypeError, solution.is_power_of_two, None)
self.assertEqual(solution.is_power_of_two(0), False)
self.assertEqual(solution.is_power_of_two(1), True)
self.assertEqual(solution.is_power_of_two(2), True)
self.assertEqual(solution.is_power_of_two(15), False)
self.assertEqual(solution.is_power_of_two(16), True)
print('Success: test_is_power_of_two')

View File

@ -74,9 +74,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class Solution(object):\n",
@ -103,24 +101,22 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"# %load test_sub_two.py\n",
"from nose.tools import assert_equal, assert_raises\n",
"import unittest\n",
"\n",
"\n",
"class TestSubTwo(object):\n",
"class TestSubTwo(unittest.TestCase):\n",
"\n",
" def test_sub_two(self):\n",
" solution = Solution()\n",
" assert_raises(TypeError, solution.sub_two, None)\n",
" assert_equal(solution.sub_two(7, 5), 2)\n",
" assert_equal(solution.sub_two(-5, -7), 2)\n",
" assert_equal(solution.sub_two(-5, 7), -12)\n",
" assert_equal(solution.sub_two(5, -7), 12)\n",
" self.assertRaises(TypeError, solution.sub_two, None)\n",
" self.assertEqual(solution.sub_two(7, 5), 2)\n",
" self.assertEqual(solution.sub_two(-5, -7), 2)\n",
" self.assertEqual(solution.sub_two(-5, 7), -12)\n",
" self.assertEqual(solution.sub_two(5, -7), 12)\n",
" print('Success: test_sub_two')\n",
"\n",
"\n",
@ -159,9 +155,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.0"
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}

View File

@ -96,9 +96,7 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class Solution(object):\n",
@ -123,9 +121,7 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@ -137,18 +133,18 @@
],
"source": [
"%%writefile test_sub_two.py\n",
"from nose.tools import assert_equal, assert_raises\n",
"import unittest\n",
"\n",
"\n",
"class TestSubTwo(object):\n",
"class TestSubTwo(unittest.TestCase):\n",
"\n",
" def test_sub_two(self):\n",
" solution = Solution()\n",
" assert_raises(TypeError, solution.sub_two, None)\n",
" assert_equal(solution.sub_two(7, 5), 2)\n",
" assert_equal(solution.sub_two(-5, -7), 2)\n",
" assert_equal(solution.sub_two(-5, 7), -12)\n",
" assert_equal(solution.sub_two(5, -7), 12)\n",
" self.assertRaises(TypeError, solution.sub_two, None)\n",
" self.assertEqual(solution.sub_two(7, 5), 2)\n",
" self.assertEqual(solution.sub_two(-5, -7), 2)\n",
" self.assertEqual(solution.sub_two(-5, 7), -12)\n",
" self.assertEqual(solution.sub_two(5, -7), 12)\n",
" print('Success: test_sub_two')\n",
"\n",
"\n",
@ -165,7 +161,6 @@
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
@ -198,9 +193,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.0"
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}

View File

@ -1,15 +1,15 @@
from nose.tools import assert_equal, assert_raises
import unittest
class TestSubTwo(object):
class TestSubTwo(unittest.TestCase):
def test_sub_two(self):
solution = Solution()
assert_raises(TypeError, solution.sub_two, None)
assert_equal(solution.sub_two(7, 5), 2)
assert_equal(solution.sub_two(-5, -7), 2)
assert_equal(solution.sub_two(-5, 7), -12)
assert_equal(solution.sub_two(5, -7), 12)
self.assertRaises(TypeError, solution.sub_two, None)
self.assertEqual(solution.sub_two(7, 5), 2)
self.assertEqual(solution.sub_two(-5, -7), 2)
self.assertEqual(solution.sub_two(-5, 7), -12)
self.assertEqual(solution.sub_two(5, -7), 12)
print('Success: test_sub_two')

View File

@ -68,9 +68,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class Solution(object):\n",
@ -97,23 +95,21 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"# %load test_sum_two.py\n",
"from nose.tools import assert_equal, assert_raises\n",
"import unittest\n",
"\n",
"\n",
"class TestSumTwo(object):\n",
"class TestSumTwo(unittest.TestCase):\n",
"\n",
" def test_sum_two(self):\n",
" solution = Solution()\n",
" assert_raises(TypeError, solution.sum_two, None)\n",
" assert_equal(solution.sum_two(5, 7), 12)\n",
" assert_equal(solution.sum_two(-5, -7), -12)\n",
" assert_equal(solution.sum_two(5, -7), -2)\n",
" self.assertRaises(TypeError, solution.sum_two, None)\n",
" self.assertEqual(solution.sum_two(5, 7), 12)\n",
" self.assertEqual(solution.sum_two(-5, -7), -12)\n",
" self.assertEqual(solution.sum_two(5, -7), -2)\n",
" print('Success: test_sum_two')\n",
"\n",
"\n",
@ -152,9 +148,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.0"
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}

View File

@ -112,9 +112,7 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class Solution(object):\n",
@ -139,9 +137,7 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@ -153,17 +149,17 @@
],
"source": [
"%%writefile test_sum_two.py\n",
"from nose.tools import assert_equal, assert_raises\n",
"import unittest\n",
"\n",
"\n",
"class TestSumTwo(object):\n",
"class TestSumTwo(unittest.TestCase):\n",
"\n",
" def test_sum_two(self):\n",
" solution = Solution()\n",
" assert_raises(TypeError, solution.sum_two, None)\n",
" assert_equal(solution.sum_two(5, 7), 12)\n",
" assert_equal(solution.sum_two(-5, -7), -12)\n",
" assert_equal(solution.sum_two(5, -7), -2)\n",
" self.assertRaises(TypeError, solution.sum_two, None)\n",
" self.assertEqual(solution.sum_two(5, 7), 12)\n",
" self.assertEqual(solution.sum_two(-5, -7), -12)\n",
" self.assertEqual(solution.sum_two(5, -7), -2)\n",
" print('Success: test_sum_two')\n",
"\n",
"\n",
@ -180,7 +176,6 @@
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
@ -213,9 +208,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.0"
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}

View File

@ -1,14 +1,14 @@
from nose.tools import assert_equal, assert_raises
import unittest
class TestSumTwo(object):
class TestSumTwo(unittest.TestCase):
def test_sum_two(self):
solution = Solution()
assert_raises(TypeError, solution.sum_two, None)
assert_equal(solution.sum_two(5, 7), 12)
assert_equal(solution.sum_two(-5, -7), -12)
assert_equal(solution.sum_two(5, -7), -2)
self.assertRaises(TypeError, solution.sum_two, None)
self.assertEqual(solution.sum_two(5, 7), 12)
self.assertEqual(solution.sum_two(-5, -7), -12)
self.assertEqual(solution.sum_two(5, -7), -2)
print('Success: test_sum_two')