mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-08 10:28:03 +00:00
@@ -82,9 +82,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class Solution(object):\n",
|
||||
@@ -115,20 +113,18 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# %load test_math_ops.py\n",
|
||||
"from nose.tools import assert_equal, assert_true, assert_raises\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestMathOps(object):\n",
|
||||
"class TestMathOps(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_math_ops(self):\n",
|
||||
" solution = Solution()\n",
|
||||
" assert_raises(TypeError, solution.insert, None)\n",
|
||||
" self.assertRaises(TypeError, solution.insert, None)\n",
|
||||
" solution.insert(5)\n",
|
||||
" solution.insert(2)\n",
|
||||
" solution.insert(7)\n",
|
||||
@@ -140,10 +136,10 @@
|
||||
" solution.insert(3)\n",
|
||||
" solution.insert(3)\n",
|
||||
" solution.insert(2)\n",
|
||||
" assert_equal(solution.max, 9)\n",
|
||||
" assert_equal(solution.min, 2)\n",
|
||||
" assert_equal(solution.mean, 5)\n",
|
||||
" assert_true(solution.mode in (2, 9))\n",
|
||||
" self.assertEqual(solution.max, 9)\n",
|
||||
" self.assertEqual(solution.min, 2)\n",
|
||||
" self.assertEqual(solution.mean, 5)\n",
|
||||
" self.assertTrue(solution.mode in (2, 9))\n",
|
||||
" print('Success: test_math_ops')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -182,9 +178,9 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.5.0"
|
||||
"version": "3.7.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
"nbformat_minor": 1
|
||||
}
|
||||
|
||||
@@ -93,9 +93,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from __future__ import division\n",
|
||||
@@ -143,9 +141,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -157,14 +153,14 @@
|
||||
],
|
||||
"source": [
|
||||
"%%writefile test_math_ops.py\n",
|
||||
"from nose.tools import assert_equal, assert_true, assert_raises\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestMathOps(object):\n",
|
||||
"class TestMathOps(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_math_ops(self):\n",
|
||||
" solution = Solution()\n",
|
||||
" assert_raises(TypeError, solution.insert, None)\n",
|
||||
" self.assertRaises(TypeError, solution.insert, None)\n",
|
||||
" solution.insert(5)\n",
|
||||
" solution.insert(2)\n",
|
||||
" solution.insert(7)\n",
|
||||
@@ -176,10 +172,10 @@
|
||||
" solution.insert(3)\n",
|
||||
" solution.insert(3)\n",
|
||||
" solution.insert(2)\n",
|
||||
" assert_equal(solution.max, 9)\n",
|
||||
" assert_equal(solution.min, 2)\n",
|
||||
" assert_equal(solution.mean, 5)\n",
|
||||
" assert_true(solution.mode in (2, 9))\n",
|
||||
" self.assertEqual(solution.max, 9)\n",
|
||||
" self.assertEqual(solution.min, 2)\n",
|
||||
" self.assertEqual(solution.mean, 5)\n",
|
||||
" self.assertTrue(solution.mode in (2, 9))\n",
|
||||
" print('Success: test_math_ops')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -195,9 +191,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -228,9 +222,9 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.5.0"
|
||||
"version": "3.7.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
"nbformat_minor": 1
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
from nose.tools import assert_equal, assert_true, assert_raises
|
||||
import unittest
|
||||
|
||||
|
||||
class TestMathOps(object):
|
||||
class TestMathOps(unittest.TestCase):
|
||||
|
||||
def test_math_ops(self):
|
||||
solution = Solution()
|
||||
assert_raises(TypeError, solution.insert, None)
|
||||
self.assertRaises(TypeError, solution.insert, None)
|
||||
solution.insert(5)
|
||||
solution.insert(2)
|
||||
solution.insert(7)
|
||||
@@ -17,10 +17,10 @@ class TestMathOps(object):
|
||||
solution.insert(3)
|
||||
solution.insert(3)
|
||||
solution.insert(2)
|
||||
assert_equal(solution.max, 9)
|
||||
assert_equal(solution.min, 2)
|
||||
assert_equal(solution.mean, 5)
|
||||
assert_true(solution.mode in (2, 9))
|
||||
self.assertEqual(solution.max, 9)
|
||||
self.assertEqual(solution.min, 2)
|
||||
self.assertEqual(solution.mean, 5)
|
||||
self.assertTrue(solution.mode in (2, 9))
|
||||
print('Success: test_math_ops')
|
||||
|
||||
|
||||
@@ -30,4 +30,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user