mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-11 03:48:03 +00:00
@@ -105,9 +105,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class Solution(object):\n",
|
||||
@@ -140,9 +138,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -154,15 +150,15 @@
|
||||
],
|
||||
"source": [
|
||||
"%%writefile test_fizz_buzz.py\n",
|
||||
"from nose.tools import assert_equal, assert_raises\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestFizzBuzz(object):\n",
|
||||
"class TestFizzBuzz(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_fizz_buzz(self):\n",
|
||||
" solution = Solution()\n",
|
||||
" assert_raises(TypeError, solution.fizz_buzz, None)\n",
|
||||
" assert_raises(ValueError, solution.fizz_buzz, 0)\n",
|
||||
" self.assertRaises(TypeError, solution.fizz_buzz, None)\n",
|
||||
" self.assertRaises(ValueError, solution.fizz_buzz, 0)\n",
|
||||
" expected = [\n",
|
||||
" '1',\n",
|
||||
" '2',\n",
|
||||
@@ -180,7 +176,7 @@
|
||||
" '14',\n",
|
||||
" 'FizzBuzz'\n",
|
||||
" ]\n",
|
||||
" assert_equal(solution.fizz_buzz(15), expected)\n",
|
||||
" self.assertEqual(solution.fizz_buzz(15), expected)\n",
|
||||
" print('Success: test_fizz_buzz')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -196,9 +192,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -211,6 +205,13 @@
|
||||
"source": [
|
||||
"%run -i test_fizz_buzz.py"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
@@ -229,9 +230,9 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.4.3"
|
||||
"version": "3.7.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
"nbformat_minor": 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user