mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-05 00:48:03 +00:00
@@ -79,9 +79,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class Solution(object):\n",
|
||||
@@ -108,24 +106,22 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# %load test_mult_other_numbers.py\n",
|
||||
"from nose.tools import assert_equal, assert_raises\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestMultOtherNumbers(object):\n",
|
||||
"class TestMultOtherNumbers(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_mult_other_numbers(self):\n",
|
||||
" solution = Solution()\n",
|
||||
" assert_raises(TypeError, solution.mult_other_numbers, None)\n",
|
||||
" assert_equal(solution.mult_other_numbers([0]), [])\n",
|
||||
" assert_equal(solution.mult_other_numbers([0, 1]), [1, 0])\n",
|
||||
" assert_equal(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.assertRaises(TypeError, solution.mult_other_numbers, None)\n",
|
||||
" self.assertEqual(solution.mult_other_numbers([0]), [])\n",
|
||||
" self.assertEqual(solution.mult_other_numbers([0, 1]), [1, 0])\n",
|
||||
" self.assertEqual(solution.mult_other_numbers([0, 1, 2]), [2, 0, 0])\n",
|
||||
" self.assertEqual(solution.mult_other_numbers([1, 2, 3, 4]), [24, 12, 8, 6])\n",
|
||||
" print('Success: test_mult_other_numbers')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -164,9 +160,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
|
||||
}
|
||||
|
||||
@@ -130,9 +130,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class Solution(object):\n",
|
||||
@@ -183,9 +181,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -197,18 +193,18 @@
|
||||
],
|
||||
"source": [
|
||||
"%%writefile test_mult_other_numbers.py\n",
|
||||
"from nose.tools import assert_equal, assert_raises\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestMultOtherNumbers(object):\n",
|
||||
"class TestMultOtherNumbers(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_mult_other_numbers(self):\n",
|
||||
" solution = Solution()\n",
|
||||
" assert_raises(TypeError, solution.mult_other_numbers, None)\n",
|
||||
" assert_equal(solution.mult_other_numbers([0]), [])\n",
|
||||
" assert_equal(solution.mult_other_numbers([0, 1]), [1, 0])\n",
|
||||
" assert_equal(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.assertRaises(TypeError, solution.mult_other_numbers, None)\n",
|
||||
" self.assertEqual(solution.mult_other_numbers([0]), [])\n",
|
||||
" self.assertEqual(solution.mult_other_numbers([0, 1]), [1, 0])\n",
|
||||
" self.assertEqual(solution.mult_other_numbers([0, 1, 2]), [2, 0, 0])\n",
|
||||
" self.assertEqual(solution.mult_other_numbers([1, 2, 3, 4]), [24, 12, 8, 6])\n",
|
||||
" print('Success: test_mult_other_numbers')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -224,9 +220,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -257,9 +251,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,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):
|
||||
solution = Solution()
|
||||
assert_raises(TypeError, solution.mult_other_numbers, None)
|
||||
assert_equal(solution.mult_other_numbers([0]), [])
|
||||
assert_equal(solution.mult_other_numbers([0, 1]), [1, 0])
|
||||
assert_equal(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.assertRaises(TypeError, solution.mult_other_numbers, None)
|
||||
self.assertEqual(solution.mult_other_numbers([0]), [])
|
||||
self.assertEqual(solution.mult_other_numbers([0, 1]), [1, 0])
|
||||
self.assertEqual(solution.mult_other_numbers([0, 1, 2]), [2, 0, 0])
|
||||
self.assertEqual(solution.mult_other_numbers([1, 2, 3, 4]), [24, 12, 8, 6])
|
||||
print('Success: test_mult_other_numbers')
|
||||
|
||||
|
||||
@@ -19,4 +19,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user