Updated unit test to use nose and moved it to Test Case section.

This commit is contained in:
Donne Martin 2015-06-22 23:19:09 -04:00
parent cf81f70c1d
commit dd64c472c1

View File

@ -46,6 +46,29 @@
"* 'foobarbaz', 'barbazfoo' -> True" "* 'foobarbaz', 'barbazfoo' -> True"
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from nose.tools import assert_equal\n",
"\n",
"class Test(object):\n",
" def test_is_rotation(self, func):\n",
" assert_equal(func('o', 'oo'), False)\n",
" assert_equal(func(None, 'foo'), False)\n",
" assert_equal(func('', 'foo'), False)\n",
" assert_equal(func('', ''), True)\n",
" assert_equal(func('foobarbaz', 'barbazfoo'), True)\n",
"\n",
"def run_tests(func):\n",
" test = Test()\n",
" test.test_is_rotation(func)"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
@ -91,11 +114,7 @@
" s3 = s1 + s1\n", " s3 = s1 + s1\n",
" return is_substring(s2, s3)\n", " return is_substring(s2, s3)\n",
"\n", "\n",
"print(is_rotation('o', 'oo'))\n", "run_tests(is_rotation)"
"print(is_rotation(None, 'foo'))\n",
"print(is_rotation('', 'foo'))\n",
"print(is_rotation('', ''))\n",
"print(is_rotation('foobarbaz', 'barbazfoo'))"
] ]
} }
], ],