#273: Remove nose dependency for online_judges/ (#282)

This commit is contained in:
Donne Martin 2020-07-14 21:34:08 -04:00 committed by GitHub
parent 67505c49b2
commit 46d3939632
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
60 changed files with 575 additions and 782 deletions

View File

@ -108,9 +108,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -137,25 +135,23 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"# %load test_assign_cookie.py\n", "# %load test_assign_cookie.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestAssignCookie(object):\n", "class TestAssignCookie(unittest.TestCase):\n",
"\n", "\n",
" def test_assign_cookie(self):\n", " def test_assign_cookie(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.find_content_children, None, None)\n", " self.assertRaises(TypeError, solution.find_content_children, None, None)\n",
" assert_equal(solution.find_content_children([1, 2, 3], \n", " self.assertEqual(solution.find_content_children([1, 2, 3], \n",
" [1, 1]), 1)\n", " [1, 1]), 1)\n",
" assert_equal(solution.find_content_children([1, 2], \n", " self.assertEqual(solution.find_content_children([1, 2], \n",
" [1, 2, 3]), 2)\n", " [1, 2, 3]), 2)\n",
" assert_equal(solution.find_content_children([7, 8, 9, 10], \n", " self.assertEqual(solution.find_content_children([7, 8, 9, 10], \n",
" [5, 6, 7, 8]), 2)\n", " [5, 6, 7, 8]), 2)\n",
" print('Success: test_find_content_children')\n", " print('Success: test_find_content_children')\n",
"\n", "\n",
@ -195,9 +191,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.4.3" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -118,9 +118,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 1,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -153,9 +151,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -167,19 +163,19 @@
], ],
"source": [ "source": [
"%%writefile test_assign_cookie.py\n", "%%writefile test_assign_cookie.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestAssignCookie(object):\n", "class TestAssignCookie(unittest.TestCase):\n",
"\n", "\n",
" def test_assign_cookie(self):\n", " def test_assign_cookie(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.find_content_children, None, None)\n", " self.assertRaises(TypeError, solution.find_content_children, None, None)\n",
" assert_equal(solution.find_content_children([1, 2, 3], \n", " self.assertEqual(solution.find_content_children([1, 2, 3], \n",
" [1, 1]), 1)\n", " [1, 1]), 1)\n",
" assert_equal(solution.find_content_children([1, 2], \n", " self.assertEqual(solution.find_content_children([1, 2], \n",
" [1, 2, 3]), 2)\n", " [1, 2, 3]), 2)\n",
" assert_equal(solution.find_content_children([7, 8, 9, 10], \n", " self.assertEqual(solution.find_content_children([7, 8, 9, 10], \n",
" [5, 6, 7, 8]), 2)\n", " [5, 6, 7, 8]), 2)\n",
" print('Success: test_find_content_children')\n", " print('Success: test_find_content_children')\n",
"\n", "\n",
@ -196,9 +192,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 3,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -229,9 +223,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.4.3" "version": "3.7.2"
} }
}, },
"nbformat": 4, "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 TestAssignCookie(object): class TestAssignCookie(unittest.TestCase):
def test_assign_cookie(self): def test_assign_cookie(self):
solution = Solution() solution = Solution()
assert_raises(TypeError, solution.find_content_children, None, None) self.assertRaises(TypeError, solution.find_content_children, None, None)
assert_equal(solution.find_content_children([1, 2, 3], self.assertEqual(solution.find_content_children([1, 2, 3],
[1, 1]), 1) [1, 1]), 1)
assert_equal(solution.find_content_children([1, 2], self.assertEqual(solution.find_content_children([1, 2],
[1, 2, 3]), 2) [1, 2, 3]), 2)
assert_equal(solution.find_content_children([7, 8, 9, 10], self.assertEqual(solution.find_content_children([7, 8, 9, 10],
[5, 6, 7, 8]), 2) [5, 6, 7, 8]), 2)
print('Success: test_find_content_children') print('Success: test_find_content_children')

View File

@ -137,9 +137,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -166,21 +164,19 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"# %load test_find_busiest_period.py\n", "# %load test_find_busiest_period.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestSolution(object):\n", "class TestSolution(unittest.TestCase):\n",
"\n", "\n",
" def test_find_busiest_period(self):\n", " def test_find_busiest_period(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.find_busiest_period, None)\n", " self.assertRaises(TypeError, solution.find_busiest_period, None)\n",
" assert_equal(solution.find_busiest_period([]), None)\n", " self.assertEqual(solution.find_busiest_period([]), None)\n",
" data = [\n", " data = [\n",
" Data(3, 2, EventType.EXIT),\n", " Data(3, 2, EventType.EXIT),\n",
" Data(1, 2, EventType.ENTER),\n", " Data(1, 2, EventType.ENTER),\n",
@ -189,7 +185,7 @@
" Data(9, 2, EventType.EXIT),\n", " Data(9, 2, EventType.EXIT),\n",
" Data(8, 2, EventType.EXIT),\n", " Data(8, 2, EventType.EXIT),\n",
" ]\n", " ]\n",
" assert_equal(solution.find_busiest_period(data), Period(7, 8))\n", " self.assertEqual(solution.find_busiest_period(data), Period(7, 8))\n",
" print('Success: test_find_busiest_period')\n", " print('Success: test_find_busiest_period')\n",
"\n", "\n",
"\n", "\n",
@ -228,9 +224,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -119,9 +119,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 1,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"from enum import Enum\n", "from enum import Enum\n",
@ -160,9 +158,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -206,9 +202,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 3,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -220,15 +214,15 @@
], ],
"source": [ "source": [
"%%writefile test_find_busiest_period.py\n", "%%writefile test_find_busiest_period.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestSolution(object):\n", "class TestSolution(unittest.TestCase):\n",
"\n", "\n",
" def test_find_busiest_period(self):\n", " def test_find_busiest_period(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.find_busiest_period, None)\n", " self.assertRaises(TypeError, solution.find_busiest_period, None)\n",
" assert_equal(solution.find_busiest_period([]), None)\n", " self.assertEqual(solution.find_busiest_period([]), None)\n",
" data = [\n", " data = [\n",
" Data(3, 2, EventType.EXIT),\n", " Data(3, 2, EventType.EXIT),\n",
" Data(1, 2, EventType.ENTER),\n", " Data(1, 2, EventType.ENTER),\n",
@ -237,7 +231,7 @@
" Data(9, 2, EventType.EXIT),\n", " Data(9, 2, EventType.EXIT),\n",
" Data(8, 2, EventType.EXIT),\n", " Data(8, 2, EventType.EXIT),\n",
" ]\n", " ]\n",
" assert_equal(solution.find_busiest_period(data), Period(7, 8))\n", " self.assertEqual(solution.find_busiest_period(data), Period(7, 8))\n",
" print('Success: test_find_busiest_period')\n", " print('Success: test_find_busiest_period')\n",
"\n", "\n",
"\n", "\n",
@ -253,9 +247,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 4,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -286,9 +278,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -1,12 +1,12 @@
from nose.tools import assert_equal, assert_raises import unittest
class TestSolution(object): class TestSolution(unittest.TestCase):
def test_find_busiest_period(self): def test_find_busiest_period(self):
solution = Solution() solution = Solution()
assert_raises(TypeError, solution.find_busiest_period, None) self.assertRaises(TypeError, solution.find_busiest_period, None)
assert_equal(solution.find_busiest_period([]), None) self.assertEqual(solution.find_busiest_period([]), None)
data = [ data = [
Data(3, 2, EventType.EXIT), Data(3, 2, EventType.EXIT),
Data(1, 2, EventType.ENTER), Data(1, 2, EventType.ENTER),
@ -15,7 +15,7 @@ class TestSolution(object):
Data(9, 2, EventType.EXIT), Data(9, 2, EventType.EXIT),
Data(8, 2, EventType.EXIT), Data(8, 2, EventType.EXIT),
] ]
assert_equal(solution.find_busiest_period(data), Period(7, 8)) self.assertEqual(solution.find_busiest_period(data), Period(7, 8))
print('Success: test_find_busiest_period') print('Success: test_find_busiest_period')

View File

@ -90,9 +90,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -119,29 +117,27 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"# %load test_island_perimeter.py\n", "# %load test_island_perimeter.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestIslandPerimeter(object):\n", "class TestIslandPerimeter(unittest.TestCase):\n",
"\n", "\n",
" def test_island_perimeter(self):\n", " def test_island_perimeter(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.island_perimeter, None)\n", " self.assertRaises(TypeError, solution.island_perimeter, None)\n",
" data = [[1, 0]]\n", " data = [[1, 0]]\n",
" expected = 4\n", " expected = 4\n",
" assert_equal(solution.island_perimeter(data), expected)\n", " self.assertEqual(solution.island_perimeter(data), expected)\n",
" data = [[0, 1, 0, 0],\n", " data = [[0, 1, 0, 0],\n",
" [1, 1, 1, 0],\n", " [1, 1, 1, 0],\n",
" [0, 1, 0, 0],\n", " [0, 1, 0, 0],\n",
" [1, 1, 0, 0]]\n", " [1, 1, 0, 0]]\n",
" expected = 16\n", " expected = 16\n",
" assert_equal(solution.island_perimeter(data), expected)\n", " self.assertEqual(solution.island_perimeter(data), expected)\n",
" print('Success: test_island_perimeter')\n", " print('Success: test_island_perimeter')\n",
"\n", "\n",
"\n", "\n",
@ -180,9 +176,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -95,9 +95,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 1,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -136,9 +134,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -150,23 +146,23 @@
], ],
"source": [ "source": [
"%%writefile test_island_perimeter.py\n", "%%writefile test_island_perimeter.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestIslandPerimeter(object):\n", "class TestIslandPerimeter(unittest.TestCase):\n",
"\n", "\n",
" def test_island_perimeter(self):\n", " def test_island_perimeter(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.island_perimeter, None)\n", " self.assertRaises(TypeError, solution.island_perimeter, None)\n",
" data = [[1, 0]]\n", " data = [[1, 0]]\n",
" expected = 4\n", " expected = 4\n",
" assert_equal(solution.island_perimeter(data), expected)\n", " self.assertEqual(solution.island_perimeter(data), expected)\n",
" data = [[0, 1, 0, 0],\n", " data = [[0, 1, 0, 0],\n",
" [1, 1, 1, 0],\n", " [1, 1, 1, 0],\n",
" [0, 1, 0, 0],\n", " [0, 1, 0, 0],\n",
" [1, 1, 0, 0]]\n", " [1, 1, 0, 0]]\n",
" expected = 16\n", " expected = 16\n",
" assert_equal(solution.island_perimeter(data), expected)\n", " self.assertEqual(solution.island_perimeter(data), expected)\n",
" print('Success: test_island_perimeter')\n", " print('Success: test_island_perimeter')\n",
"\n", "\n",
"\n", "\n",
@ -182,9 +178,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 3,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -215,9 +209,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.4.3" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -1,20 +1,20 @@
from nose.tools import assert_equal, assert_raises import unittest
class TestIslandPerimeter(object): class TestIslandPerimeter(unittest.TestCase):
def test_island_perimeter(self): def test_island_perimeter(self):
solution = Solution() solution = Solution()
assert_raises(TypeError, solution.island_perimeter, None) self.assertRaises(TypeError, solution.island_perimeter, None)
data = [[1, 0]] data = [[1, 0]]
expected = 4 expected = 4
assert_equal(solution.island_perimeter(data), expected) self.assertEqual(solution.island_perimeter(data), expected)
data = [[0, 1, 0, 0], data = [[0, 1, 0, 0],
[1, 1, 1, 0], [1, 1, 1, 0],
[0, 1, 0, 0], [0, 1, 0, 0],
[1, 1, 0, 0]] [1, 1, 0, 0]]
expected = 16 expected = 16
assert_equal(solution.island_perimeter(data), expected) self.assertEqual(solution.island_perimeter(data), expected)
print('Success: test_island_perimeter') print('Success: test_island_perimeter')

View File

@ -102,9 +102,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -131,32 +129,30 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"# %load test_format_license_key.py\n", "# %load test_format_license_key.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestSolution(object):\n", "class TestSolution(unittest.TestCase):\n",
"\n", "\n",
" def test_format_license_key(self):\n", " def test_format_license_key(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.format_license_key, None, None)\n", " self.assertRaises(TypeError, solution.format_license_key, None, None)\n",
" license_key = '---'\n", " license_key = '---'\n",
" k = 3\n", " k = 3\n",
" expected = ''\n", " expected = ''\n",
" assert_equal(solution.format_license_key(license_key, k), expected)\n", " self.assertEqual(solution.format_license_key(license_key, k), expected)\n",
" license_key = '2-4A0r7-4k'\n", " license_key = '2-4A0r7-4k'\n",
" k = 3\n", " k = 3\n",
" expected = '24-A0R-74K'\n", " expected = '24-A0R-74K'\n",
" assert_equal(solution.format_license_key(license_key, k), expected)\n", " self.assertEqual(solution.format_license_key(license_key, k), expected)\n",
" license_key = '2-4A0r7-4k'\n", " license_key = '2-4A0r7-4k'\n",
" k = 4\n", " k = 4\n",
" expected = '24A0-R74K'\n", " expected = '24A0-R74K'\n",
" assert_equal(solution.format_license_key(license_key, k), expected)\n", " self.assertEqual(solution.format_license_key(license_key, k), expected)\n",
" print('Success: test_format_license_key')\n", " print('Success: test_format_license_key')\n",
"\n", "\n",
"def main():\n", "def main():\n",
@ -194,9 +190,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -110,9 +110,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 1,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -147,9 +145,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -161,26 +157,26 @@
], ],
"source": [ "source": [
"%%writefile test_format_license_key.py\n", "%%writefile test_format_license_key.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestSolution(object):\n", "class TestSolution(unittest.TestCase):\n",
"\n", "\n",
" def test_format_license_key(self):\n", " def test_format_license_key(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.format_license_key, None, None)\n", " self.assertRaises(TypeError, solution.format_license_key, None, None)\n",
" license_key = '---'\n", " license_key = '---'\n",
" k = 3\n", " k = 3\n",
" expected = ''\n", " expected = ''\n",
" assert_equal(solution.format_license_key(license_key, k), expected)\n", " self.assertEqual(solution.format_license_key(license_key, k), expected)\n",
" license_key = '2-4A0r7-4k'\n", " license_key = '2-4A0r7-4k'\n",
" k = 3\n", " k = 3\n",
" expected = '24-A0R-74K'\n", " expected = '24-A0R-74K'\n",
" assert_equal(solution.format_license_key(license_key, k), expected)\n", " self.assertEqual(solution.format_license_key(license_key, k), expected)\n",
" license_key = '2-4A0r7-4k'\n", " license_key = '2-4A0r7-4k'\n",
" k = 4\n", " k = 4\n",
" expected = '24A0-R74K'\n", " expected = '24A0-R74K'\n",
" assert_equal(solution.format_license_key(license_key, k), expected)\n", " self.assertEqual(solution.format_license_key(license_key, k), expected)\n",
" print('Success: test_format_license_key')\n", " print('Success: test_format_license_key')\n",
"\n", "\n",
"def main():\n", "def main():\n",
@ -195,9 +191,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 3,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -228,9 +222,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -1,23 +1,23 @@
from nose.tools import assert_equal, assert_raises import unittest
class TestSolution(object): class TestSolution(unittest.TestCase):
def test_format_license_key(self): def test_format_license_key(self):
solution = Solution() solution = Solution()
assert_raises(TypeError, solution.format_license_key, None, None) self.assertRaises(TypeError, solution.format_license_key, None, None)
license_key = '---' license_key = '---'
k = 3 k = 3
expected = '' expected = ''
assert_equal(solution.format_license_key(license_key, k), expected) self.assertEqual(solution.format_license_key(license_key, k), expected)
license_key = '2-4A0r7-4k' license_key = '2-4A0r7-4k'
k = 3 k = 3
expected = '24-A0R-74K' expected = '24-A0R-74K'
assert_equal(solution.format_license_key(license_key, k), expected) self.assertEqual(solution.format_license_key(license_key, k), expected)
license_key = '2-4A0r7-4k' license_key = '2-4A0r7-4k'
k = 4 k = 4
expected = '24A0-R74K' expected = '24A0-R74K'
assert_equal(solution.format_license_key(license_key, k), expected) self.assertEqual(solution.format_license_key(license_key, k), expected)
print('Success: test_format_license_key') print('Success: test_format_license_key')
def main(): def main():

View File

@ -113,9 +113,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -142,24 +140,22 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"# %load test_length_longest_path.py\n", "# %load test_length_longest_path.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestSolution(object):\n", "class TestSolution(unittest.TestCase):\n",
"\n", "\n",
" def test_length_longest_path(self):\n", " def test_length_longest_path(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.length_longest_path, None)\n", " self.assertRaises(TypeError, solution.length_longest_path, None)\n",
" assert_equal(solution.length_longest_path(''), 0)\n", " self.assertEqual(solution.length_longest_path(''), 0)\n",
" file_system = 'dir\\n\\tsubdir1\\n\\t\\tfile1.ext\\n\\t\\tsubsubdir1\\n\\tsubdir2\\n\\t\\tsubsubdir2\\n\\t\\t\\tfile2.ext'\n", " file_system = 'dir\\n\\tsubdir1\\n\\t\\tfile1.ext\\n\\t\\tsubsubdir1\\n\\tsubdir2\\n\\t\\tsubsubdir2\\n\\t\\t\\tfile2.ext'\n",
" expected = 32\n", " expected = 32\n",
" assert_equal(solution.length_longest_path(file_system), expected)\n", " self.assertEqual(solution.length_longest_path(file_system), expected)\n",
" print('Success: test_length_longest_path')\n", " print('Success: test_length_longest_path')\n",
"\n", "\n",
"\n", "\n",
@ -198,9 +194,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -128,9 +128,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 1,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -160,9 +158,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -174,18 +170,18 @@
], ],
"source": [ "source": [
"%%writefile test_length_longest_path.py\n", "%%writefile test_length_longest_path.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestSolution(object):\n", "class TestSolution(unittest.TestCase):\n",
"\n", "\n",
" def test_length_longest_path(self):\n", " def test_length_longest_path(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.length_longest_path, None)\n", " self.assertRaises(TypeError, solution.length_longest_path, None)\n",
" assert_equal(solution.length_longest_path(''), 0)\n", " self.assertEqual(solution.length_longest_path(''), 0)\n",
" file_system = 'dir\\n\\tsubdir1\\n\\t\\tfile1.ext\\n\\t\\tsubsubdir1\\n\\tsubdir2\\n\\t\\tsubsubdir2\\n\\t\\t\\tfile2.ext'\n", " file_system = 'dir\\n\\tsubdir1\\n\\t\\tfile1.ext\\n\\t\\tsubsubdir1\\n\\tsubdir2\\n\\t\\tsubsubdir2\\n\\t\\t\\tfile2.ext'\n",
" expected = 32\n", " expected = 32\n",
" assert_equal(solution.length_longest_path(file_system), expected)\n", " self.assertEqual(solution.length_longest_path(file_system), expected)\n",
" print('Success: test_length_longest_path')\n", " print('Success: test_length_longest_path')\n",
"\n", "\n",
"\n", "\n",
@ -201,9 +197,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 3,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -234,9 +228,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "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 TestSolution(object): class TestSolution(unittest.TestCase):
def test_length_longest_path(self): def test_length_longest_path(self):
solution = Solution() solution = Solution()
assert_raises(TypeError, solution.length_longest_path, None) self.assertRaises(TypeError, solution.length_longest_path, None)
assert_equal(solution.length_longest_path(''), 0) self.assertEqual(solution.length_longest_path(''), 0)
file_system = 'dir\n\tsubdir1\n\t\tfile1.ext\n\t\tsubsubdir1\n\tsubdir2\n\t\tsubsubdir2\n\t\t\tfile2.ext' file_system = 'dir\n\tsubdir1\n\t\tfile1.ext\n\t\tsubsubdir1\n\tsubdir2\n\t\tsubsubdir2\n\t\t\tfile2.ext'
expected = 32 expected = 32
assert_equal(solution.length_longest_path(file_system), expected) self.assertEqual(solution.length_longest_path(file_system), expected)
print('Success: test_length_longest_path') print('Success: test_length_longest_path')

View File

@ -79,9 +79,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -108,23 +106,21 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"# %load test_longest_substr.py\n", "# %load test_longest_substr.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestSolution(object):\n", "class TestSolution(unittest.TestCase):\n",
"\n", "\n",
" def test_longest_substr(self):\n", " def test_longest_substr(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.longest_substr, None)\n", " self.assertRaises(TypeError, solution.longest_substr, None)\n",
" assert_equal(solution.longest_substr('', k=3), 0)\n", " self.assertEqual(solution.longest_substr('', k=3), 0)\n",
" assert_equal(solution.longest_substr('abcabcdefgghiij', k=3), 6)\n", " self.assertEqual(solution.longest_substr('abcabcdefgghiij', k=3), 6)\n",
" assert_equal(solution.longest_substr('abcabcdefgghighij', k=3), 7)\n", " self.assertEqual(solution.longest_substr('abcabcdefgghighij', k=3), 7)\n",
" print('Success: test_longest_substr')\n", " print('Success: test_longest_substr')\n",
"\n", "\n",
"\n", "\n",
@ -163,9 +159,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.4.3" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -92,9 +92,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 1,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -127,9 +125,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -141,17 +137,17 @@
], ],
"source": [ "source": [
"%%writefile test_longest_substr.py\n", "%%writefile test_longest_substr.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestSolution(object):\n", "class TestSolution(unittest.TestCase):\n",
"\n", "\n",
" def test_longest_substr(self):\n", " def test_longest_substr(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.longest_substr, None)\n", " self.assertRaises(TypeError, solution.longest_substr, None)\n",
" assert_equal(solution.longest_substr('', k=3), 0)\n", " self.assertEqual(solution.longest_substr('', k=3), 0)\n",
" assert_equal(solution.longest_substr('abcabcdefgghiij', k=3), 6)\n", " self.assertEqual(solution.longest_substr('abcabcdefgghiij', k=3), 6)\n",
" assert_equal(solution.longest_substr('abcabcdefgghighij', k=3), 7)\n", " self.assertEqual(solution.longest_substr('abcabcdefgghighij', k=3), 7)\n",
" print('Success: test_longest_substr')\n", " print('Success: test_longest_substr')\n",
"\n", "\n",
"\n", "\n",
@ -167,9 +163,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 3,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -200,9 +194,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "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 TestSolution(object): class TestSolution(unittest.TestCase):
def test_longest_substr(self): def test_longest_substr(self):
solution = Solution() solution = Solution()
assert_raises(TypeError, solution.longest_substr, None) self.assertRaises(TypeError, solution.longest_substr, None)
assert_equal(solution.longest_substr('', k=3), 0) self.assertEqual(solution.longest_substr('', k=3), 0)
assert_equal(solution.longest_substr('abcabcdefgghiij', k=3), 6) self.assertEqual(solution.longest_substr('abcabcdefgghiij', k=3), 6)
assert_equal(solution.longest_substr('abcabcdefgghighij', k=3), 7) self.assertEqual(solution.longest_substr('abcabcdefgghighij', k=3), 7)
print('Success: test_longest_substr') print('Success: test_longest_substr')

View File

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

View File

@ -84,10 +84,8 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": 1,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"from __future__ import division\n", "from __future__ import division\n",
@ -134,10 +132,8 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 13, "execution_count": 2,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -149,14 +145,14 @@
], ],
"source": [ "source": [
"%%writefile test_math_ops.py\n", "%%writefile test_math_ops.py\n",
"from nose.tools import assert_equal, assert_true, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestMathOps(object):\n", "class TestMathOps(unittest.TestCase):\n",
"\n", "\n",
" def test_math_ops(self):\n", " def test_math_ops(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.insert, None)\n", " self.assertRaises(TypeError, solution.insert, None)\n",
" solution.insert(5)\n", " solution.insert(5)\n",
" solution.insert(2)\n", " solution.insert(2)\n",
" solution.insert(7)\n", " solution.insert(7)\n",
@ -168,10 +164,10 @@
" solution.insert(3)\n", " solution.insert(3)\n",
" solution.insert(3)\n", " solution.insert(3)\n",
" solution.insert(2)\n", " solution.insert(2)\n",
" assert_equal(solution.max, 9)\n", " self.assertEqual(solution.max, 9)\n",
" assert_equal(solution.min, 2)\n", " self.assertEqual(solution.min, 2)\n",
" assert_equal(solution.mean, 5)\n", " self.assertEqual(solution.mean, 5)\n",
" assert_true(solution.mode in (2, 9))\n", " self.assertTrue(solution.mode in (2, 9))\n",
" print('Success: test_math_ops')\n", " print('Success: test_math_ops')\n",
"\n", "\n",
"\n", "\n",
@ -186,23 +182,14 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 14, "execution_count": 3,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"ename": "AssertionError", "name": "stdout",
"evalue": "False is not true", "output_type": "stream",
"output_type": "error", "text": [
"traceback": [ "Success: test_math_ops\n"
"\u001b[0;31m---------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m/Users/donnemartin/Dev/github/sources/interactive-coding-challenges/online_judges/math_ops/test_math_ops.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 31\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 32\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0m__name__\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m'__main__'\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 33\u001b[0;31m \u001b[0mmain\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m/Users/donnemartin/Dev/github/sources/interactive-coding-challenges/online_judges/math_ops/test_math_ops.py\u001b[0m in \u001b[0;36mmain\u001b[0;34m()\u001b[0m\n\u001b[1;32m 27\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mmain\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 28\u001b[0m \u001b[0mtest\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mTestMathOps\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 29\u001b[0;31m \u001b[0mtest\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtest_math_ops\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 30\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 31\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Users/donnemartin/Dev/github/sources/interactive-coding-challenges/online_judges/math_ops/test_math_ops.py\u001b[0m in \u001b[0;36mtest_math_ops\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 21\u001b[0m \u001b[0massert_equal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msolution\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmin\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 22\u001b[0m \u001b[0massert_equal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msolution\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmean\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m5\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 23\u001b[0;31m \u001b[0massert_true\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msolution\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmode\u001b[0m \u001b[0;32min\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m92\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 24\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Success: test_math_ops'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Users/donnemartin/.pyenv/versions/3.5.0/lib/python3.5/unittest/case.py\u001b[0m in \u001b[0;36massertTrue\u001b[0;34m(self, expr, msg)\u001b[0m\n\u001b[1;32m 672\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 673\u001b[0m \u001b[0mmsg\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_formatMessage\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmsg\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"%s is not true\"\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0msafe_repr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexpr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 674\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfailureException\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmsg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 675\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 676\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_formatMessage\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmsg\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstandardMsg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mAssertionError\u001b[0m: False is not true"
] ]
} }
], ],
@ -227,9 +214,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "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): def test_math_ops(self):
solution = Solution() solution = Solution()
assert_raises(TypeError, solution.insert, None) self.assertRaises(TypeError, solution.insert, None)
solution.insert(5) solution.insert(5)
solution.insert(2) solution.insert(2)
solution.insert(7) solution.insert(7)
@ -17,10 +17,10 @@ class TestMathOps(object):
solution.insert(3) solution.insert(3)
solution.insert(3) solution.insert(3)
solution.insert(2) solution.insert(2)
assert_equal(solution.max, 9) self.assertEqual(solution.max, 9)
assert_equal(solution.min, 2) self.assertEqual(solution.min, 2)
assert_equal(solution.mean, 5) self.assertEqual(solution.mean, 5)
assert_true(solution.mode in (2, 92)) self.assertTrue(solution.mode in (2, 9))
print('Success: test_math_ops') print('Success: test_math_ops')

View File

@ -83,9 +83,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -112,23 +110,21 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"# %load test_max_profit.py\n", "# %load test_max_profit.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestMaxProfit(object):\n", "class TestMaxProfit(unittest.TestCase):\n",
"\n", "\n",
" def test_max_profit(self):\n", " def test_max_profit(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.find_max_profit, None)\n", " self.assertRaises(TypeError, solution.find_max_profit, None)\n",
" assert_raises(ValueError, solution.find_max_profit, [])\n", " self.assertRaises(ValueError, solution.find_max_profit, [])\n",
" assert_equal(solution.find_max_profit([8, 5, 3, 2, 1]), -1)\n", " self.assertEqual(solution.find_max_profit([8, 5, 3, 2, 1]), -1)\n",
" assert_equal(solution.find_max_profit([5, 3, 7, 4, 2, 6, 9]), 7)\n", " self.assertEqual(solution.find_max_profit([5, 3, 7, 4, 2, 6, 9]), 7)\n",
" print('Success: test_max_profit')\n", " print('Success: test_max_profit')\n",
"\n", "\n",
"\n", "\n",
@ -167,9 +163,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -90,9 +90,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 1,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"import sys\n", "import sys\n",
@ -124,9 +122,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -138,17 +134,17 @@
], ],
"source": [ "source": [
"%%writefile test_max_profit.py\n", "%%writefile test_max_profit.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestMaxProfit(object):\n", "class TestMaxProfit(unittest.TestCase):\n",
"\n", "\n",
" def test_max_profit(self):\n", " def test_max_profit(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.find_max_profit, None)\n", " self.assertRaises(TypeError, solution.find_max_profit, None)\n",
" assert_raises(ValueError, solution.find_max_profit, [])\n", " self.assertRaises(ValueError, solution.find_max_profit, [])\n",
" assert_equal(solution.find_max_profit([8, 5, 3, 2, 1]), -1)\n", " self.assertEqual(solution.find_max_profit([8, 5, 3, 2, 1]), -1)\n",
" assert_equal(solution.find_max_profit([5, 3, 7, 4, 2, 6, 9]), 7)\n", " self.assertEqual(solution.find_max_profit([5, 3, 7, 4, 2, 6, 9]), 7)\n",
" print('Success: test_max_profit')\n", " print('Success: test_max_profit')\n",
"\n", "\n",
"\n", "\n",
@ -164,9 +160,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 3,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -197,9 +191,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "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 TestMaxProfit(object): class TestMaxProfit(unittest.TestCase):
def test_max_profit(self): def test_max_profit(self):
solution = Solution() solution = Solution()
assert_raises(TypeError, solution.find_max_profit, None) self.assertRaises(TypeError, solution.find_max_profit, None)
assert_raises(ValueError, solution.find_max_profit, []) self.assertRaises(ValueError, solution.find_max_profit, [])
assert_equal(solution.find_max_profit([8, 5, 3, 2, 1]), -1) self.assertEqual(solution.find_max_profit([8, 5, 3, 2, 1]), -1)
assert_equal(solution.find_max_profit([5, 3, 7, 4, 2, 6, 9]), 7) self.assertEqual(solution.find_max_profit([5, 3, 7, 4, 2, 6, 9]), 7)
print('Success: test_max_profit') print('Success: test_max_profit')

View File

@ -67,9 +67,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -91,20 +89,18 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"# %load test_maximizing_xor.py\n", "# %load test_maximizing_xor.py\n",
"from nose.tools import assert_equal\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestMaximizingXor(object):\n", "class TestMaximizingXor(unittest.TestCase):\n",
"\n", "\n",
" def test_maximizing_xor(self):\n", " def test_maximizing_xor(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_equal(solution.max_xor(10, 15), 7)\n", " self.assertEqual(solution.max_xor(10, 15), 7)\n",
" print('Success: test_maximizing_xor')\n", " print('Success: test_maximizing_xor')\n",
"\n", "\n",
"\n", "\n",
@ -143,9 +139,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -77,9 +77,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 1,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -105,9 +103,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -119,14 +115,14 @@
], ],
"source": [ "source": [
"%%writefile test_maximizing_xor.py\n", "%%writefile test_maximizing_xor.py\n",
"from nose.tools import assert_equal\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestMaximizingXor(object):\n", "class TestMaximizingXor(unittest.TestCase):\n",
"\n", "\n",
" def test_maximizing_xor(self):\n", " def test_maximizing_xor(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_equal(solution.max_xor(10, 15), 7)\n", " self.assertEqual(solution.max_xor(10, 15), 7)\n",
" print('Success: test_maximizing_xor')\n", " print('Success: test_maximizing_xor')\n",
"\n", "\n",
"\n", "\n",
@ -142,9 +138,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 3,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -175,9 +169,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -1,11 +1,11 @@
from nose.tools import assert_equal import unittest
class TestMaximizingXor(object): class TestMaximizingXor(unittest.TestCase):
def test_maximizing_xor(self): def test_maximizing_xor(self):
solution = Solution() solution = Solution()
assert_equal(solution.max_xor(10, 15), 7) self.assertEqual(solution.max_xor(10, 15), 7)
print('Success: test_maximizing_xor') print('Success: test_maximizing_xor')

View File

@ -89,9 +89,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -118,30 +116,28 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"# %load test_merge_ranges.py\n", "# %load test_merge_ranges.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestMergeRanges(object):\n", "class TestMergeRanges(unittest.TestCase):\n",
"\n", "\n",
" def test_merge_ranges(self):\n", " def test_merge_ranges(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.merge_ranges, None)\n", " self.assertRaises(TypeError, solution.merge_ranges, None)\n",
" assert_equal(solution.merge_ranges([]), [])\n", " self.assertEqual(solution.merge_ranges([]), [])\n",
" array = [(2, 3), (7, 9)]\n", " array = [(2, 3), (7, 9)]\n",
" expected = [(2, 3), (7, 9)]\n", " expected = [(2, 3), (7, 9)]\n",
" assert_equal(solution.merge_ranges(array), expected)\n", " self.assertEqual(solution.merge_ranges(array), expected)\n",
" array = [(2, 3), (3, 5), (7, 9), (8, 10)]\n", " array = [(2, 3), (3, 5), (7, 9), (8, 10)]\n",
" expected = [(2, 5), (7, 10)]\n", " expected = [(2, 5), (7, 10)]\n",
" assert_equal(solution.merge_ranges(array), expected)\n", " self.assertEqual(solution.merge_ranges(array), expected)\n",
" array = [(2, 3), (3, 5), (7, 9), (8, 10), (1, 11)]\n", " array = [(2, 3), (3, 5), (7, 9), (8, 10), (1, 11)]\n",
" expected = [(1, 11)]\n", " expected = [(1, 11)]\n",
" assert_equal(solution.merge_ranges(array), expected)\n", " self.assertEqual(solution.merge_ranges(array), expected)\n",
" print('Success: test_merge_ranges')\n", " print('Success: test_merge_ranges')\n",
"\n", "\n",
"\n", "\n",
@ -180,9 +176,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -130,9 +130,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 1,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -168,9 +166,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -182,24 +178,24 @@
], ],
"source": [ "source": [
"%%writefile test_merge_ranges.py\n", "%%writefile test_merge_ranges.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestMergeRanges(object):\n", "class TestMergeRanges(unittest.TestCase):\n",
"\n", "\n",
" def test_merge_ranges(self):\n", " def test_merge_ranges(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.merge_ranges, None)\n", " self.assertRaises(TypeError, solution.merge_ranges, None)\n",
" assert_equal(solution.merge_ranges([]), [])\n", " self.assertEqual(solution.merge_ranges([]), [])\n",
" array = [(2, 3), (7, 9)]\n", " array = [(2, 3), (7, 9)]\n",
" expected = [(2, 3), (7, 9)]\n", " expected = [(2, 3), (7, 9)]\n",
" assert_equal(solution.merge_ranges(array), expected)\n", " self.assertEqual(solution.merge_ranges(array), expected)\n",
" array = [(3, 5), (2, 3), (7, 9), (8, 10)]\n", " array = [(3, 5), (2, 3), (7, 9), (8, 10)]\n",
" expected = [(2, 5), (7, 10)]\n", " expected = [(2, 5), (7, 10)]\n",
" assert_equal(solution.merge_ranges(array), expected)\n", " self.assertEqual(solution.merge_ranges(array), expected)\n",
" array = [(2, 3), (3, 5), (7, 9), (8, 10), (1, 11)]\n", " array = [(2, 3), (3, 5), (7, 9), (8, 10), (1, 11)]\n",
" expected = [(1, 11)]\n", " expected = [(1, 11)]\n",
" assert_equal(solution.merge_ranges(array), expected)\n", " self.assertEqual(solution.merge_ranges(array), expected)\n",
" print('Success: test_merge_ranges')\n", " print('Success: test_merge_ranges')\n",
"\n", "\n",
"\n", "\n",
@ -215,9 +211,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 3,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -248,9 +242,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.4.3" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -1,21 +1,21 @@
from nose.tools import assert_equal, assert_raises import unittest
class TestMergeRanges(object): class TestMergeRanges(unittest.TestCase):
def test_merge_ranges(self): def test_merge_ranges(self):
solution = Solution() solution = Solution()
assert_raises(TypeError, solution.merge_ranges, None) self.assertRaises(TypeError, solution.merge_ranges, None)
assert_equal(solution.merge_ranges([]), []) self.assertEqual(solution.merge_ranges([]), [])
array = [(2, 3), (7, 9)] array = [(2, 3), (7, 9)]
expected = [(2, 3), (7, 9)] expected = [(2, 3), (7, 9)]
assert_equal(solution.merge_ranges(array), expected) self.assertEqual(solution.merge_ranges(array), expected)
array = [(3, 5), (2, 3), (7, 9), (8, 10)] array = [(3, 5), (2, 3), (7, 9), (8, 10)]
expected = [(2, 5), (7, 10)] expected = [(2, 5), (7, 10)]
assert_equal(solution.merge_ranges(array), expected) self.assertEqual(solution.merge_ranges(array), expected)
array = [(2, 3), (3, 5), (7, 9), (8, 10), (1, 11)] array = [(2, 3), (3, 5), (7, 9), (8, 10), (1, 11)]
expected = [(1, 11)] expected = [(1, 11)]
assert_equal(solution.merge_ranges(array), expected) self.assertEqual(solution.merge_ranges(array), expected)
print('Success: test_merge_ranges') print('Success: test_merge_ranges')

View File

@ -82,9 +82,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -111,38 +109,36 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"# %load test_move_zeroes.py\n", "# %load test_move_zeroes.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestMoveZeroes(object):\n", "class TestMoveZeroes(unittest.TestCase):\n",
"\n", "\n",
" def test_move_zeroes(self):\n", " def test_move_zeroes(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.move_zeroes, None)\n", " self.assertRaises(TypeError, solution.move_zeroes, None)\n",
" array = [0, 1, 0, 3, 12]\n", " array = [0, 1, 0, 3, 12]\n",
" solution.move_zeroes(array)\n", " solution.move_zeroes(array)\n",
" assert_equal(array, [1, 3, 12, 0, 0])\n", " self.assertEqual(array, [1, 3, 12, 0, 0])\n",
" array = [1, 0]\n", " array = [1, 0]\n",
" solution.move_zeroes(array)\n", " solution.move_zeroes(array)\n",
" assert_equal(array, [1, 0])\n", " self.assertEqual(array, [1, 0])\n",
" array = [0, 1]\n", " array = [0, 1]\n",
" solution.move_zeroes(array)\n", " solution.move_zeroes(array)\n",
" assert_equal(array, [1, 0])\n", " self.assertEqual(array, [1, 0])\n",
" array = [0]\n", " array = [0]\n",
" solution.move_zeroes(array)\n", " solution.move_zeroes(array)\n",
" assert_equal(array, [0])\n", " self.assertEqual(array, [0])\n",
" array = [1]\n", " array = [1]\n",
" solution.move_zeroes(array)\n", " solution.move_zeroes(array)\n",
" assert_equal(array, [1])\n", " self.assertEqual(array, [1])\n",
" array = [1, 1]\n", " array = [1, 1]\n",
" solution.move_zeroes(array)\n", " solution.move_zeroes(array)\n",
" assert_equal(array, [1, 1])\n", " self.assertEqual(array, [1, 1])\n",
" print('Success: test_move_zeroes')\n", " print('Success: test_move_zeroes')\n",
"\n", "\n",
"\n", "\n",
@ -181,9 +177,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -125,9 +125,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 1,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -154,9 +152,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -168,32 +164,32 @@
], ],
"source": [ "source": [
"%%writefile test_move_zeroes.py\n", "%%writefile test_move_zeroes.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestMoveZeroes(object):\n", "class TestMoveZeroes(unittest.TestCase):\n",
"\n", "\n",
" def test_move_zeroes(self):\n", " def test_move_zeroes(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.move_zeroes, None)\n", " self.assertRaises(TypeError, solution.move_zeroes, None)\n",
" array = [0, 1, 0, 3, 12]\n", " array = [0, 1, 0, 3, 12]\n",
" solution.move_zeroes(array)\n", " solution.move_zeroes(array)\n",
" assert_equal(array, [1, 3, 12, 0, 0])\n", " self.assertEqual(array, [1, 3, 12, 0, 0])\n",
" array = [1, 0]\n", " array = [1, 0]\n",
" solution.move_zeroes(array)\n", " solution.move_zeroes(array)\n",
" assert_equal(array, [1, 0])\n", " self.assertEqual(array, [1, 0])\n",
" array = [0, 1]\n", " array = [0, 1]\n",
" solution.move_zeroes(array)\n", " solution.move_zeroes(array)\n",
" assert_equal(array, [1, 0])\n", " self.assertEqual(array, [1, 0])\n",
" array = [0]\n", " array = [0]\n",
" solution.move_zeroes(array)\n", " solution.move_zeroes(array)\n",
" assert_equal(array, [0])\n", " self.assertEqual(array, [0])\n",
" array = [1]\n", " array = [1]\n",
" solution.move_zeroes(array)\n", " solution.move_zeroes(array)\n",
" assert_equal(array, [1])\n", " self.assertEqual(array, [1])\n",
" array = [1, 1]\n", " array = [1, 1]\n",
" solution.move_zeroes(array)\n", " solution.move_zeroes(array)\n",
" assert_equal(array, [1, 1])\n", " self.assertEqual(array, [1, 1])\n",
" print('Success: test_move_zeroes')\n", " print('Success: test_move_zeroes')\n",
"\n", "\n",
"\n", "\n",
@ -209,9 +205,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 3,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -242,9 +236,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.4.3" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -1,29 +1,29 @@
from nose.tools import assert_equal, assert_raises import unittest
class TestMoveZeroes(object): class TestMoveZeroes(unittest.TestCase):
def test_move_zeroes(self): def test_move_zeroes(self):
solution = Solution() solution = Solution()
assert_raises(TypeError, solution.move_zeroes, None) self.assertRaises(TypeError, solution.move_zeroes, None)
array = [0, 1, 0, 3, 12] array = [0, 1, 0, 3, 12]
solution.move_zeroes(array) solution.move_zeroes(array)
assert_equal(array, [1, 3, 12, 0, 0]) self.assertEqual(array, [1, 3, 12, 0, 0])
array = [1, 0] array = [1, 0]
solution.move_zeroes(array) solution.move_zeroes(array)
assert_equal(array, [1, 0]) self.assertEqual(array, [1, 0])
array = [0, 1] array = [0, 1]
solution.move_zeroes(array) solution.move_zeroes(array)
assert_equal(array, [1, 0]) self.assertEqual(array, [1, 0])
array = [0] array = [0]
solution.move_zeroes(array) solution.move_zeroes(array)
assert_equal(array, [0]) self.assertEqual(array, [0])
array = [1] array = [1]
solution.move_zeroes(array) solution.move_zeroes(array)
assert_equal(array, [1]) self.assertEqual(array, [1])
array = [1, 1] array = [1, 1]
solution.move_zeroes(array) solution.move_zeroes(array)
assert_equal(array, [1, 1]) self.assertEqual(array, [1, 1])
print('Success: test_move_zeroes') print('Success: test_move_zeroes')

View File

@ -79,9 +79,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -108,24 +106,22 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"# %load test_mult_other_numbers.py\n", "# %load test_mult_other_numbers.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestMultOtherNumbers(object):\n", "class TestMultOtherNumbers(unittest.TestCase):\n",
"\n", "\n",
" def test_mult_other_numbers(self):\n", " def test_mult_other_numbers(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.mult_other_numbers, None)\n", " self.assertRaises(TypeError, solution.mult_other_numbers, None)\n",
" assert_equal(solution.mult_other_numbers([0]), [])\n", " self.assertEqual(solution.mult_other_numbers([0]), [])\n",
" assert_equal(solution.mult_other_numbers([0, 1]), [1, 0])\n", " self.assertEqual(solution.mult_other_numbers([0, 1]), [1, 0])\n",
" assert_equal(solution.mult_other_numbers([0, 1, 2]), [2, 0, 0])\n", " self.assertEqual(solution.mult_other_numbers([0, 1, 2]), [2, 0, 0])\n",
" assert_equal(solution.mult_other_numbers([1, 2, 3, 4]), [24, 12, 8, 6])\n", " self.assertEqual(solution.mult_other_numbers([1, 2, 3, 4]), [24, 12, 8, 6])\n",
" print('Success: test_mult_other_numbers')\n", " print('Success: test_mult_other_numbers')\n",
"\n", "\n",
"\n", "\n",
@ -164,9 +160,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -130,9 +130,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 1,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -183,9 +181,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -197,18 +193,18 @@
], ],
"source": [ "source": [
"%%writefile test_mult_other_numbers.py\n", "%%writefile test_mult_other_numbers.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestMultOtherNumbers(object):\n", "class TestMultOtherNumbers(unittest.TestCase):\n",
"\n", "\n",
" def test_mult_other_numbers(self):\n", " def test_mult_other_numbers(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.mult_other_numbers, None)\n", " self.assertRaises(TypeError, solution.mult_other_numbers, None)\n",
" assert_equal(solution.mult_other_numbers([0]), [])\n", " self.assertEqual(solution.mult_other_numbers([0]), [])\n",
" assert_equal(solution.mult_other_numbers([0, 1]), [1, 0])\n", " self.assertEqual(solution.mult_other_numbers([0, 1]), [1, 0])\n",
" assert_equal(solution.mult_other_numbers([0, 1, 2]), [2, 0, 0])\n", " self.assertEqual(solution.mult_other_numbers([0, 1, 2]), [2, 0, 0])\n",
" assert_equal(solution.mult_other_numbers([1, 2, 3, 4]), [24, 12, 8, 6])\n", " self.assertEqual(solution.mult_other_numbers([1, 2, 3, 4]), [24, 12, 8, 6])\n",
" print('Success: test_mult_other_numbers')\n", " print('Success: test_mult_other_numbers')\n",
"\n", "\n",
"\n", "\n",
@ -224,9 +220,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 3,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -257,9 +251,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "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 TestMultOtherNumbers(object): class TestMultOtherNumbers(unittest.TestCase):
def test_mult_other_numbers(self): def test_mult_other_numbers(self):
solution = Solution() solution = Solution()
assert_raises(TypeError, solution.mult_other_numbers, None) self.assertRaises(TypeError, solution.mult_other_numbers, None)
assert_equal(solution.mult_other_numbers([0]), []) self.assertEqual(solution.mult_other_numbers([0]), [])
assert_equal(solution.mult_other_numbers([0, 1]), [1, 0]) self.assertEqual(solution.mult_other_numbers([0, 1]), [1, 0])
assert_equal(solution.mult_other_numbers([0, 1, 2]), [2, 0, 0]) self.assertEqual(solution.mult_other_numbers([0, 1, 2]), [2, 0, 0])
assert_equal(solution.mult_other_numbers([1, 2, 3, 4]), [24, 12, 8, 6]) self.assertEqual(solution.mult_other_numbers([1, 2, 3, 4]), [24, 12, 8, 6])
print('Success: test_mult_other_numbers') print('Success: test_mult_other_numbers')

View File

@ -84,9 +84,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -113,26 +111,24 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"# %load test_can_win_nim.py\n", "# %load test_can_win_nim.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestSolution(object):\n", "class TestSolution(unittest.TestCase):\n",
"\n", "\n",
" def test_can_win_nim(self):\n", " def test_can_win_nim(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.can_win_nim, None)\n", " self.assertRaises(TypeError, solution.can_win_nim, None)\n",
" assert_equal(solution.can_win_nim(1), True)\n", " self.assertEqual(solution.can_win_nim(1), True)\n",
" assert_equal(solution.can_win_nim(2), True)\n", " self.assertEqual(solution.can_win_nim(2), True)\n",
" assert_equal(solution.can_win_nim(3), True)\n", " self.assertEqual(solution.can_win_nim(3), True)\n",
" assert_equal(solution.can_win_nim(4), False)\n", " self.assertEqual(solution.can_win_nim(4), False)\n",
" assert_equal(solution.can_win_nim(7), True)\n", " self.assertEqual(solution.can_win_nim(7), True)\n",
" assert_equal(solution.can_win_nim(40), False)\n", " self.assertEqual(solution.can_win_nim(40), False)\n",
" print('Success: test_can_win_nim')\n", " print('Success: test_can_win_nim')\n",
"\n", "\n",
"\n", "\n",
@ -171,9 +167,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -87,9 +87,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 1,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -108,9 +106,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -122,20 +118,20 @@
], ],
"source": [ "source": [
"%%writefile test_can_win_nim.py\n", "%%writefile test_can_win_nim.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestSolution(object):\n", "class TestSolution(unittest.TestCase):\n",
"\n", "\n",
" def test_can_win_nim(self):\n", " def test_can_win_nim(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.can_win_nim, None)\n", " self.assertRaises(TypeError, solution.can_win_nim, None)\n",
" assert_equal(solution.can_win_nim(1), True)\n", " self.assertEqual(solution.can_win_nim(1), True)\n",
" assert_equal(solution.can_win_nim(2), True)\n", " self.assertEqual(solution.can_win_nim(2), True)\n",
" assert_equal(solution.can_win_nim(3), True)\n", " self.assertEqual(solution.can_win_nim(3), True)\n",
" assert_equal(solution.can_win_nim(4), False)\n", " self.assertEqual(solution.can_win_nim(4), False)\n",
" assert_equal(solution.can_win_nim(7), True)\n", " self.assertEqual(solution.can_win_nim(7), True)\n",
" assert_equal(solution.can_win_nim(40), False)\n", " self.assertEqual(solution.can_win_nim(40), False)\n",
" print('Success: test_can_win_nim')\n", " print('Success: test_can_win_nim')\n",
"\n", "\n",
"\n", "\n",
@ -151,9 +147,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 3,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -184,9 +178,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -1,17 +1,17 @@
from nose.tools import assert_equal, assert_raises import unittest
class TestSolution(object): class TestSolution(unittest.TestCase):
def test_can_win_nim(self): def test_can_win_nim(self):
solution = Solution() solution = Solution()
assert_raises(TypeError, solution.can_win_nim, None) self.assertRaises(TypeError, solution.can_win_nim, None)
assert_equal(solution.can_win_nim(1), True) self.assertEqual(solution.can_win_nim(1), True)
assert_equal(solution.can_win_nim(2), True) self.assertEqual(solution.can_win_nim(2), True)
assert_equal(solution.can_win_nim(3), True) self.assertEqual(solution.can_win_nim(3), True)
assert_equal(solution.can_win_nim(4), False) self.assertEqual(solution.can_win_nim(4), False)
assert_equal(solution.can_win_nim(7), True) self.assertEqual(solution.can_win_nim(7), True)
assert_equal(solution.can_win_nim(40), False) self.assertEqual(solution.can_win_nim(40), False)
print('Success: test_can_win_nim') print('Success: test_can_win_nim')

View File

@ -79,9 +79,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -108,23 +106,21 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"# %load test_prod_three.py\n", "# %load test_prod_three.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestProdThree(object):\n", "class TestProdThree(unittest.TestCase):\n",
"\n", "\n",
" def test_prod_three(self):\n", " def test_prod_three(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.max_prod_three, None)\n", " self.assertRaises(TypeError, solution.max_prod_three, None)\n",
" assert_raises(ValueError, solution.max_prod_three, [1, 2])\n", " self.assertRaises(ValueError, solution.max_prod_three, [1, 2])\n",
" assert_equal(solution.max_prod_three([5, -2, 3]), -30)\n", " self.assertEqual(solution.max_prod_three([5, -2, 3]), -30)\n",
" assert_equal(solution.max_prod_three([5, -2, 3, 1, -1, 4]), 60)\n", " self.assertEqual(solution.max_prod_three([5, -2, 3, 1, -1, 4]), 60)\n",
" print('Success: test_prod_three')\n", " print('Success: test_prod_three')\n",
"\n", "\n",
"\n", "\n",
@ -163,9 +159,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -145,9 +145,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 1,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -198,9 +196,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -212,17 +208,17 @@
], ],
"source": [ "source": [
"%%writefile test_prod_three.py\n", "%%writefile test_prod_three.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestProdThree(object):\n", "class TestProdThree(unittest.TestCase):\n",
"\n", "\n",
" def test_prod_three(self):\n", " def test_prod_three(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.max_prod_three, None)\n", " self.assertRaises(TypeError, solution.max_prod_three, None)\n",
" assert_raises(ValueError, solution.max_prod_three, [1, 2])\n", " self.assertRaises(ValueError, solution.max_prod_three, [1, 2])\n",
" assert_equal(solution.max_prod_three([5, -2, 3]), -30)\n", " self.assertEqual(solution.max_prod_three([5, -2, 3]), -30)\n",
" assert_equal(solution.max_prod_three([5, -2, 3, 1, -1, 4]), 60)\n", " self.assertEqual(solution.max_prod_three([5, -2, 3, 1, -1, 4]), 60)\n",
" print('Success: test_prod_three')\n", " print('Success: test_prod_three')\n",
"\n", "\n",
"\n", "\n",
@ -238,9 +234,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 3,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -271,9 +265,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.4.3" "version": "3.7.2"
} }
}, },
"nbformat": 4, "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 TestProdThree(object): class TestProdThree(unittest.TestCase):
def test_prod_three(self): def test_prod_three(self):
solution = Solution() solution = Solution()
assert_raises(TypeError, solution.max_prod_three, None) self.assertRaises(TypeError, solution.max_prod_three, None)
assert_raises(ValueError, solution.max_prod_three, [1, 2]) self.assertRaises(ValueError, solution.max_prod_three, [1, 2])
assert_equal(solution.max_prod_three([5, -2, 3]), -30) self.assertEqual(solution.max_prod_three([5, -2, 3]), -30)
assert_equal(solution.max_prod_three([5, -2, 3, 1, -1, 4]), 60) self.assertEqual(solution.max_prod_three([5, -2, 3, 1, -1, 4]), 60)
print('Success: test_prod_three') print('Success: test_prod_three')

View File

@ -78,9 +78,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -107,24 +105,22 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"# %load test_ransom_note.py\n", "# %load test_ransom_note.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestRansomNote(object):\n", "class TestRansomNote(unittest.TestCase):\n",
"\n", "\n",
" def test_ransom_note(self):\n", " def test_ransom_note(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.match_note_to_magazine, None, None)\n", " self.assertRaises(TypeError, solution.match_note_to_magazine, None, None)\n",
" assert_equal(solution.match_note_to_magazine('', ''), True)\n", " self.assertEqual(solution.match_note_to_magazine('', ''), True)\n",
" assert_equal(solution.match_note_to_magazine('a', 'b'), False)\n", " self.assertEqual(solution.match_note_to_magazine('a', 'b'), False)\n",
" assert_equal(solution.match_note_to_magazine('aa', 'ab'), False)\n", " self.assertEqual(solution.match_note_to_magazine('aa', 'ab'), False)\n",
" assert_equal(solution.match_note_to_magazine('aa', 'aab'), True)\n", " self.assertEqual(solution.match_note_to_magazine('aa', 'aab'), True)\n",
" print('Success: test_ransom_note')\n", " print('Success: test_ransom_note')\n",
"\n", "\n",
"\n", "\n",
@ -163,9 +159,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -83,9 +83,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 1,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -119,9 +117,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -133,18 +129,18 @@
], ],
"source": [ "source": [
"%%writefile test_ransom_note.py\n", "%%writefile test_ransom_note.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestRansomNote(object):\n", "class TestRansomNote(unittest.TestCase):\n",
"\n", "\n",
" def test_ransom_note(self):\n", " def test_ransom_note(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.match_note_to_magazine, None, None)\n", " self.assertRaises(TypeError, solution.match_note_to_magazine, None, None)\n",
" assert_equal(solution.match_note_to_magazine('', ''), True)\n", " self.assertEqual(solution.match_note_to_magazine('', ''), True)\n",
" assert_equal(solution.match_note_to_magazine('a', 'b'), False)\n", " self.assertEqual(solution.match_note_to_magazine('a', 'b'), False)\n",
" assert_equal(solution.match_note_to_magazine('aa', 'ab'), False)\n", " self.assertEqual(solution.match_note_to_magazine('aa', 'ab'), False)\n",
" assert_equal(solution.match_note_to_magazine('aa', 'aab'), True)\n", " self.assertEqual(solution.match_note_to_magazine('aa', 'aab'), True)\n",
" print('Success: test_ransom_note')\n", " print('Success: test_ransom_note')\n",
"\n", "\n",
"\n", "\n",
@ -160,9 +156,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 3,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -193,9 +187,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "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 TestRansomNote(object): class TestRansomNote(unittest.TestCase):
def test_ransom_note(self): def test_ransom_note(self):
solution = Solution() solution = Solution()
assert_raises(TypeError, solution.match_note_to_magazine, None, None) self.assertRaises(TypeError, solution.match_note_to_magazine, None, None)
assert_equal(solution.match_note_to_magazine('', ''), True) self.assertEqual(solution.match_note_to_magazine('', ''), True)
assert_equal(solution.match_note_to_magazine('a', 'b'), False) self.assertEqual(solution.match_note_to_magazine('a', 'b'), False)
assert_equal(solution.match_note_to_magazine('aa', 'ab'), False) self.assertEqual(solution.match_note_to_magazine('aa', 'ab'), False)
assert_equal(solution.match_note_to_magazine('aa', 'aab'), True) self.assertEqual(solution.match_note_to_magazine('aa', 'aab'), True)
print('Success: test_ransom_note') print('Success: test_ransom_note')

View File

@ -135,9 +135,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -164,34 +162,32 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"# %load test_count_sentence_fit.py\n", "# %load test_count_sentence_fit.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestSolution(object):\n", "class TestSolution(unittest.TestCase):\n",
"\n", "\n",
" def test_count_sentence_fit(self):\n", " def test_count_sentence_fit(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.count_sentence_fit, \n", " self.assertRaises(TypeError, solution.count_sentence_fit, \n",
" None, None, None)\n", " None, None, None)\n",
" assert_raises(ValueError, solution.count_sentence_fit, \n", " self.assertRaises(ValueError, solution.count_sentence_fit, \n",
" 'abc', rows=-1, cols=-1)\n", " 'abc', rows=-1, cols=-1)\n",
" sentence = [\"hello\", \"world\"]\n", " sentence = [\"hello\", \"world\"]\n",
" expected = 1\n", " expected = 1\n",
" assert_equal(solution.count_sentence_fit(sentence, rows=2, cols=8),\n", " self.assertEqual(solution.count_sentence_fit(sentence, rows=2, cols=8),\n",
" expected)\n", " expected)\n",
" sentence = [\"a\", \"bcd\", \"e\"]\n", " sentence = [\"a\", \"bcd\", \"e\"]\n",
" expected = 2\n", " expected = 2\n",
" assert_equal(solution.count_sentence_fit(sentence, rows=3, cols=6),\n", " self.assertEqual(solution.count_sentence_fit(sentence, rows=3, cols=6),\n",
" expected)\n", " expected)\n",
" sentence = [\"I\", \"had\", \"apple\", \"pie\"]\n", " sentence = [\"I\", \"had\", \"apple\", \"pie\"]\n",
" expected = 1\n", " expected = 1\n",
" assert_equal(solution.count_sentence_fit(sentence, rows=4, cols=5),\n", " self.assertEqual(solution.count_sentence_fit(sentence, rows=4, cols=5),\n",
" expected)\n", " expected)\n",
" print('Success: test_count_sentence_fit')\n", " print('Success: test_count_sentence_fit')\n",
"\n", "\n",
@ -231,9 +227,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -153,9 +153,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 1,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -228,9 +226,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -242,28 +238,28 @@
], ],
"source": [ "source": [
"%%writefile test_count_sentence_fit.py\n", "%%writefile test_count_sentence_fit.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestSolution(object):\n", "class TestSolution(unittest.TestCase):\n",
"\n", "\n",
" def test_count_sentence_fit(self):\n", " def test_count_sentence_fit(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.count_sentence_fit, \n", " self.assertRaises(TypeError, solution.count_sentence_fit, \n",
" None, None, None)\n", " None, None, None)\n",
" assert_raises(ValueError, solution.count_sentence_fit, \n", " self.assertRaises(ValueError, solution.count_sentence_fit, \n",
" 'abc', rows=-1, cols=-1)\n", " 'abc', rows=-1, cols=-1)\n",
" sentence = [\"hello\", \"world\"]\n", " sentence = [\"hello\", \"world\"]\n",
" expected = 1\n", " expected = 1\n",
" assert_equal(solution.count_sentence_fit(sentence, rows=2, cols=8),\n", " self.assertEqual(solution.count_sentence_fit(sentence, rows=2, cols=8),\n",
" expected)\n", " expected)\n",
" sentence = [\"a\", \"bcd\", \"e\"]\n", " sentence = [\"a\", \"bcd\", \"e\"]\n",
" expected = 2\n", " expected = 2\n",
" assert_equal(solution.count_sentence_fit(sentence, rows=3, cols=6),\n", " self.assertEqual(solution.count_sentence_fit(sentence, rows=3, cols=6),\n",
" expected)\n", " expected)\n",
" sentence = [\"I\", \"had\", \"apple\", \"pie\"]\n", " sentence = [\"I\", \"had\", \"apple\", \"pie\"]\n",
" expected = 1\n", " expected = 1\n",
" assert_equal(solution.count_sentence_fit(sentence, rows=4, cols=5),\n", " self.assertEqual(solution.count_sentence_fit(sentence, rows=4, cols=5),\n",
" expected)\n", " expected)\n",
" print('Success: test_count_sentence_fit')\n", " print('Success: test_count_sentence_fit')\n",
"\n", "\n",
@ -280,9 +276,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 3,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -313,9 +307,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -1,25 +1,25 @@
from nose.tools import assert_equal, assert_raises import unittest
class TestSolution(object): class TestSolution(unittest.TestCase):
def test_count_sentence_fit(self): def test_count_sentence_fit(self):
solution = Solution() solution = Solution()
assert_raises(TypeError, solution.count_sentence_fit, self.assertRaises(TypeError, solution.count_sentence_fit,
None, None, None) None, None, None)
assert_raises(ValueError, solution.count_sentence_fit, self.assertRaises(ValueError, solution.count_sentence_fit,
'abc', rows=-1, cols=-1) 'abc', rows=-1, cols=-1)
sentence = ["hello", "world"] sentence = ["hello", "world"]
expected = 1 expected = 1
assert_equal(solution.count_sentence_fit(sentence, rows=2, cols=8), self.assertEqual(solution.count_sentence_fit(sentence, rows=2, cols=8),
expected) expected)
sentence = ["a", "bcd", "e"] sentence = ["a", "bcd", "e"]
expected = 2 expected = 2
assert_equal(solution.count_sentence_fit(sentence, rows=3, cols=6), self.assertEqual(solution.count_sentence_fit(sentence, rows=3, cols=6),
expected) expected)
sentence = ["I", "had", "apple", "pie"] sentence = ["I", "had", "apple", "pie"]
expected = 1 expected = 1
assert_equal(solution.count_sentence_fit(sentence, rows=4, cols=5), self.assertEqual(solution.count_sentence_fit(sentence, rows=4, cols=5),
expected) expected)
print('Success: test_count_sentence_fit') print('Success: test_count_sentence_fit')

View File

@ -75,9 +75,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -104,21 +102,19 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"# %load test_str_diff.py\n", "# %load test_str_diff.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestFindDiff(object):\n", "class TestFindDiff(unittest.TestCase):\n",
"\n", "\n",
" def test_find_diff(self):\n", " def test_find_diff(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.find_diff, None)\n", " self.assertRaises(TypeError, solution.find_diff, None)\n",
" assert_equal(solution.find_diff('aaabbcdd', 'abdbacade'), 'e')\n", " self.assertEqual(solution.find_diff('aaabbcdd', 'abdbacade'), 'e')\n",
" print('Success: test_find_diff')\n", " print('Success: test_find_diff')\n",
"\n", "\n",
"\n", "\n",
@ -157,9 +153,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -80,9 +80,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 1,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -116,9 +114,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -130,15 +126,15 @@
], ],
"source": [ "source": [
"%%writefile test_str_diff.py\n", "%%writefile test_str_diff.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestFindDiff(object):\n", "class TestFindDiff(unittest.TestCase):\n",
"\n", "\n",
" def test_find_diff(self):\n", " def test_find_diff(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.find_diff, None)\n", " self.assertRaises(TypeError, solution.find_diff, None)\n",
" assert_equal(solution.find_diff('aaabbcdd', 'abdbacade'), 'e')\n", " self.assertEqual(solution.find_diff('aaabbcdd', 'abdbacade'), 'e')\n",
" print('Success: test_find_diff')\n", " print('Success: test_find_diff')\n",
"\n", "\n",
"\n", "\n",
@ -154,9 +150,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 3,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -187,9 +181,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -1,12 +1,12 @@
from nose.tools import assert_equal, assert_raises import unittest
class TestFindDiff(object): class TestFindDiff(unittest.TestCase):
def test_find_diff(self): def test_find_diff(self):
solution = Solution() solution = Solution()
assert_raises(TypeError, solution.find_diff, None) self.assertRaises(TypeError, solution.find_diff, None)
assert_equal(solution.find_diff('aaabbcdd', 'abdbacade'), 'e') self.assertEqual(solution.find_diff('aaabbcdd', 'abdbacade'), 'e')
print('Success: test_find_diff') print('Success: test_find_diff')

View File

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

View File

@ -100,9 +100,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 1,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -127,9 +125,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -141,18 +137,18 @@
], ],
"source": [ "source": [
"%%writefile test_sub_two.py\n", "%%writefile test_sub_two.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestSubTwo(object):\n", "class TestSubTwo(unittest.TestCase):\n",
"\n", "\n",
" def test_sub_two(self):\n", " def test_sub_two(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.sub_two, None)\n", " self.assertRaises(TypeError, solution.sub_two, None)\n",
" assert_equal(solution.sub_two(7, 5), 2)\n", " self.assertEqual(solution.sub_two(7, 5), 2)\n",
" assert_equal(solution.sub_two(-5, -7), 2)\n", " self.assertEqual(solution.sub_two(-5, -7), 2)\n",
" assert_equal(solution.sub_two(-5, 7), -12)\n", " self.assertEqual(solution.sub_two(-5, 7), -12)\n",
" assert_equal(solution.sub_two(5, -7), 12)\n", " self.assertEqual(solution.sub_two(5, -7), 12)\n",
" print('Success: test_sub_two')\n", " print('Success: test_sub_two')\n",
"\n", "\n",
"\n", "\n",
@ -169,7 +165,6 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 3,
"metadata": { "metadata": {
"collapsed": false,
"scrolled": true "scrolled": true
}, },
"outputs": [ "outputs": [
@ -202,9 +197,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "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): def test_sub_two(self):
solution = Solution() solution = Solution()
assert_raises(TypeError, solution.sub_two, None) self.assertRaises(TypeError, solution.sub_two, None)
assert_equal(solution.sub_two(7, 5), 2) self.assertEqual(solution.sub_two(7, 5), 2)
assert_equal(solution.sub_two(-5, -7), 2) self.assertEqual(solution.sub_two(-5, -7), 2)
assert_equal(solution.sub_two(-5, 7), -12) self.assertEqual(solution.sub_two(-5, 7), -12)
assert_equal(solution.sub_two(5, -7), 12) self.assertEqual(solution.sub_two(5, -7), 12)
print('Success: test_sub_two') print('Success: test_sub_two')

View File

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

View File

@ -116,9 +116,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 1,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -143,9 +141,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -157,17 +153,17 @@
], ],
"source": [ "source": [
"%%writefile test_sum_two.py\n", "%%writefile test_sum_two.py\n",
"from nose.tools import assert_equal, assert_raises\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestSumTwo(object):\n", "class TestSumTwo(unittest.TestCase):\n",
"\n", "\n",
" def test_sum_two(self):\n", " def test_sum_two(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_raises(TypeError, solution.sum_two, None)\n", " self.assertRaises(TypeError, solution.sum_two, None)\n",
" assert_equal(solution.sum_two(5, 7), 12)\n", " self.assertEqual(solution.sum_two(5, 7), 12)\n",
" assert_equal(solution.sum_two(-5, -7), -12)\n", " self.assertEqual(solution.sum_two(-5, -7), -12)\n",
" assert_equal(solution.sum_two(5, -7), -2)\n", " self.assertEqual(solution.sum_two(5, -7), -2)\n",
" print('Success: test_sum_two')\n", " print('Success: test_sum_two')\n",
"\n", "\n",
"\n", "\n",
@ -184,7 +180,6 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 3,
"metadata": { "metadata": {
"collapsed": false,
"scrolled": true "scrolled": true
}, },
"outputs": [ "outputs": [
@ -217,9 +212,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "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): def test_sum_two(self):
solution = Solution() solution = Solution()
assert_raises(TypeError, solution.sum_two, None) self.assertRaises(TypeError, solution.sum_two, None)
assert_equal(solution.sum_two(5, 7), 12) self.assertEqual(solution.sum_two(5, 7), 12)
assert_equal(solution.sum_two(-5, -7), -12) self.assertEqual(solution.sum_two(-5, -7), -12)
assert_equal(solution.sum_two(5, -7), -2) self.assertEqual(solution.sum_two(5, -7), -2)
print('Success: test_sum_two') print('Success: test_sum_two')

View File

@ -1,13 +1,13 @@
from nose.tools import assert_equal import unittest
class TestUtopianTree(object): class TestUtopianTree(unittest.TestCase):
def test_utopian_tree(self): def test_utopian_tree(self):
solution = Solution() solution = Solution()
assert_equal(solution.calc_utopian_tree_height(0), 1) self.assertEqual(solution.calc_utopian_tree_height(0), 1)
assert_equal(solution.calc_utopian_tree_height(1), 2) self.assertEqual(solution.calc_utopian_tree_height(1), 2)
assert_equal(solution.calc_utopian_tree_height(4), 7) self.assertEqual(solution.calc_utopian_tree_height(4), 7)
print('Success: test_utopian_tree') print('Success: test_utopian_tree')

View File

@ -67,9 +67,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -91,22 +89,20 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"# %load test_utopian_tree.py\n", "# %load test_utopian_tree.py\n",
"from nose.tools import assert_equal\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestUtopianTree(object):\n", "class TestUtopianTree(unittest.TestCase):\n",
"\n", "\n",
" def test_utopian_tree(self):\n", " def test_utopian_tree(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_equal(solution.calc_utopian_tree_height(0), 1)\n", " self.assertEqual(solution.calc_utopian_tree_height(0), 1)\n",
" assert_equal(solution.calc_utopian_tree_height(1), 2)\n", " self.assertEqual(solution.calc_utopian_tree_height(1), 2)\n",
" assert_equal(solution.calc_utopian_tree_height(4), 7)\n", " self.assertEqual(solution.calc_utopian_tree_height(4), 7)\n",
" print('Success: test_utopian_tree')\n", " print('Success: test_utopian_tree')\n",
"\n", "\n",
"\n", "\n",
@ -145,9 +141,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -74,9 +74,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 1,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"class Solution(object):\n", "class Solution(object):\n",
@ -104,9 +102,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -118,16 +114,16 @@
], ],
"source": [ "source": [
"%%writefile test_utopian_tree.py\n", "%%writefile test_utopian_tree.py\n",
"from nose.tools import assert_equal\n", "import unittest\n",
"\n", "\n",
"\n", "\n",
"class TestUtopianTree(object):\n", "class TestUtopianTree(unittest.TestCase):\n",
"\n", "\n",
" def test_utopian_tree(self):\n", " def test_utopian_tree(self):\n",
" solution = Solution()\n", " solution = Solution()\n",
" assert_equal(solution.calc_utopian_tree_height(0), 1)\n", " self.assertEqual(solution.calc_utopian_tree_height(0), 1)\n",
" assert_equal(solution.calc_utopian_tree_height(1), 2)\n", " self.assertEqual(solution.calc_utopian_tree_height(1), 2)\n",
" assert_equal(solution.calc_utopian_tree_height(4), 7)\n", " self.assertEqual(solution.calc_utopian_tree_height(4), 7)\n",
" print('Success: test_utopian_tree')\n", " print('Success: test_utopian_tree')\n",
"\n", "\n",
"\n", "\n",
@ -143,9 +139,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 3,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -176,9 +170,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.0" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }