From 67505c49b24e49e881ec22adc96d02acd80f1be3 Mon Sep 17 00:00:00 2001 From: Donne Martin Date: Tue, 14 Jul 2020 21:23:57 -0400 Subject: [PATCH] #273: Remove nose dependency for math_probability/ (#281) --- .../add_digits/add_digits_challenge.ipynb | 28 +++++++--------- .../add_digits/add_digits_solution.ipynb | 32 ++++++++----------- .../add_digits/test_add_digits.py | 18 +++++------ .../check_prime/check_prime_challenge.ipynb | 26 +++++++-------- .../check_prime/check_prime_solution.ipynb | 30 +++++++---------- .../check_prime/test_check_prime.py | 16 +++++----- .../check_prime_challenge.ipynb | 22 ++++++------- .../check_prime_solution.ipynb | 26 ++++++--------- .../generate_primes/test_generate_primes.py | 12 +++---- .../math_ops/math_ops_challenge.ipynb | 26 +++++++-------- .../math_ops/math_ops_solution.ipynb | 30 +++++++---------- math_probability/math_ops/test_math_ops.py | 16 +++++----- .../power_two/power_two_challenge.ipynb | 28 +++++++--------- .../power_two/power_two_solution.ipynb | 32 ++++++++----------- .../power_two/test_is_power_of_two.py | 18 +++++------ .../sub_two/sub_two_challenge.ipynb | 26 +++++++-------- .../sub_two/sub_two_solution.ipynb | 27 +++++++--------- math_probability/sub_two/test_sub_two.py | 16 +++++----- .../sum_two/sum_two_challenge.ipynb | 24 ++++++-------- .../sum_two/sum_two_solution.ipynb | 25 ++++++--------- math_probability/sum_two/test_sum_two.py | 14 ++++---- 21 files changed, 212 insertions(+), 280 deletions(-) diff --git a/math_probability/add_digits/add_digits_challenge.ipynb b/math_probability/add_digits/add_digits_challenge.ipynb index 6fbdabd..08d7949 100644 --- a/math_probability/add_digits/add_digits_challenge.ipynb +++ b/math_probability/add_digits/add_digits_challenge.ipynb @@ -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 } diff --git a/math_probability/add_digits/add_digits_solution.ipynb b/math_probability/add_digits/add_digits_solution.ipynb index a0c7781..84db559 100644 --- a/math_probability/add_digits/add_digits_solution.ipynb +++ b/math_probability/add_digits/add_digits_solution.ipynb @@ -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 } diff --git a/math_probability/add_digits/test_add_digits.py b/math_probability/add_digits/test_add_digits.py index dd3d289..d42b896 100644 --- a/math_probability/add_digits/test_add_digits.py +++ b/math_probability/add_digits/test_add_digits.py @@ -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') @@ -26,4 +26,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/math_probability/check_prime/check_prime_challenge.ipynb b/math_probability/check_prime/check_prime_challenge.ipynb index c7d4433..3d559c2 100644 --- a/math_probability/check_prime/check_prime_challenge.ipynb +++ b/math_probability/check_prime/check_prime_challenge.ipynb @@ -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 } diff --git a/math_probability/check_prime/check_prime_solution.ipynb b/math_probability/check_prime/check_prime_solution.ipynb index 858ca7a..2fae74b 100644 --- a/math_probability/check_prime/check_prime_solution.ipynb +++ b/math_probability/check_prime/check_prime_solution.ipynb @@ -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 } diff --git a/math_probability/check_prime/test_check_prime.py b/math_probability/check_prime/test_check_prime.py index 83ad691..8094886 100644 --- a/math_probability/check_prime/test_check_prime.py +++ b/math_probability/check_prime/test_check_prime.py @@ -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') @@ -19,4 +19,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/math_probability/generate_primes/check_prime_challenge.ipynb b/math_probability/generate_primes/check_prime_challenge.ipynb index a9aaf97..100fde5 100644 --- a/math_probability/generate_primes/check_prime_challenge.ipynb +++ b/math_probability/generate_primes/check_prime_challenge.ipynb @@ -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 } diff --git a/math_probability/generate_primes/check_prime_solution.ipynb b/math_probability/generate_primes/check_prime_solution.ipynb index 1dcc4c6..4ac5799 100644 --- a/math_probability/generate_primes/check_prime_solution.ipynb +++ b/math_probability/generate_primes/check_prime_solution.ipynb @@ -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 } diff --git a/math_probability/generate_primes/test_generate_primes.py b/math_probability/generate_primes/test_generate_primes.py index 85ed132..a5ce27d 100644 --- a/math_probability/generate_primes/test_generate_primes.py +++ b/math_probability/generate_primes/test_generate_primes.py @@ -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, @@ -23,4 +23,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/math_probability/math_ops/math_ops_challenge.ipynb b/math_probability/math_ops/math_ops_challenge.ipynb index 8257a9b..374f60b 100644 --- a/math_probability/math_ops/math_ops_challenge.ipynb +++ b/math_probability/math_ops/math_ops_challenge.ipynb @@ -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 } diff --git a/math_probability/math_ops/math_ops_solution.ipynb b/math_probability/math_ops/math_ops_solution.ipynb index 7af7159..b734974 100644 --- a/math_probability/math_ops/math_ops_solution.ipynb +++ b/math_probability/math_ops/math_ops_solution.ipynb @@ -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 } diff --git a/math_probability/math_ops/test_math_ops.py b/math_probability/math_ops/test_math_ops.py index 1e1c18a..4431819 100644 --- a/math_probability/math_ops/test_math_ops.py +++ b/math_probability/math_ops/test_math_ops.py @@ -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') @@ -30,4 +30,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/math_probability/power_two/power_two_challenge.ipynb b/math_probability/power_two/power_two_challenge.ipynb index 4815a68..8287351 100644 --- a/math_probability/power_two/power_two_challenge.ipynb +++ b/math_probability/power_two/power_two_challenge.ipynb @@ -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 } diff --git a/math_probability/power_two/power_two_solution.ipynb b/math_probability/power_two/power_two_solution.ipynb index 9e67bf4..7c089dd 100644 --- a/math_probability/power_two/power_two_solution.ipynb +++ b/math_probability/power_two/power_two_solution.ipynb @@ -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 } diff --git a/math_probability/power_two/test_is_power_of_two.py b/math_probability/power_two/test_is_power_of_two.py index bdc3ab2..fa4262e 100644 --- a/math_probability/power_two/test_is_power_of_two.py +++ b/math_probability/power_two/test_is_power_of_two.py @@ -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') @@ -20,4 +20,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/math_probability/sub_two/sub_two_challenge.ipynb b/math_probability/sub_two/sub_two_challenge.ipynb index 704e278..19c0abc 100644 --- a/math_probability/sub_two/sub_two_challenge.ipynb +++ b/math_probability/sub_two/sub_two_challenge.ipynb @@ -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 } diff --git a/math_probability/sub_two/sub_two_solution.ipynb b/math_probability/sub_two/sub_two_solution.ipynb index 93ff274..dbc511f 100644 --- a/math_probability/sub_two/sub_two_solution.ipynb +++ b/math_probability/sub_two/sub_two_solution.ipynb @@ -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 } diff --git a/math_probability/sub_two/test_sub_two.py b/math_probability/sub_two/test_sub_two.py index f022a3f..aab56e8 100644 --- a/math_probability/sub_two/test_sub_two.py +++ b/math_probability/sub_two/test_sub_two.py @@ -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') @@ -19,4 +19,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/math_probability/sum_two/sum_two_challenge.ipynb b/math_probability/sum_two/sum_two_challenge.ipynb index 1346c49..2152b0f 100644 --- a/math_probability/sum_two/sum_two_challenge.ipynb +++ b/math_probability/sum_two/sum_two_challenge.ipynb @@ -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 } diff --git a/math_probability/sum_two/sum_two_solution.ipynb b/math_probability/sum_two/sum_two_solution.ipynb index cfba2a3..0a19e49 100644 --- a/math_probability/sum_two/sum_two_solution.ipynb +++ b/math_probability/sum_two/sum_two_solution.ipynb @@ -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 } diff --git a/math_probability/sum_two/test_sum_two.py b/math_probability/sum_two/test_sum_two.py index 82a5ada..10b5b93 100644 --- a/math_probability/sum_two/test_sum_two.py +++ b/math_probability/sum_two/test_sum_two.py @@ -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') @@ -18,4 +18,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main()