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