From dd64c472c167c24caa5ef45b626041e41f25ad61 Mon Sep 17 00:00:00 2001 From: Donne Martin Date: Mon, 22 Jun 2015 23:19:09 -0400 Subject: [PATCH] Updated unit test to use nose and moved it to Test Case section. --- arrays-strings/rotation.ipynb | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/arrays-strings/rotation.ipynb b/arrays-strings/rotation.ipynb index 39959db..4f9bff8 100644 --- a/arrays-strings/rotation.ipynb +++ b/arrays-strings/rotation.ipynb @@ -46,6 +46,29 @@ "* '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", "metadata": {}, @@ -91,11 +114,7 @@ " s3 = s1 + s1\n", " return is_substring(s2, s3)\n", "\n", - "print(is_rotation('o', 'oo'))\n", - "print(is_rotation(None, 'foo'))\n", - "print(is_rotation('', 'foo'))\n", - "print(is_rotation('', ''))\n", - "print(is_rotation('foobarbaz', 'barbazfoo'))" + "run_tests(is_rotation)" ] } ],