#273: Remove nose dependency for staging/ (#283)

This commit is contained in:
Donne Martin 2020-07-15 20:19:14 -04:00 committed by GitHub
parent 46d3939632
commit 0236a45a94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 170 additions and 189 deletions

View File

@ -100,20 +100,24 @@
"metadata": {},
"outputs": [],
"source": [
"from nose.tools import assert_equal\n",
"import unittest\n",
"\n",
"\n",
"class UnitTest(unittest.TestCase):\n",
"\n",
"class UnitTest (object):\n",
" def testReverseWords(self, func):\n",
" assert_equal(func('the sun is hot'), 'eht nus si toh')\n",
" assert_equal(func(''), None)\n",
" assert_equal(func('123 456 789'), '321 654 987')\n",
" assert_equal(func('magic'), 'cigam')\n",
" self.assertEqual(func('the sun is hot'), 'eht nus si toh')\n",
" self.assertEqual(func(''), None)\n",
" self.assertEqual(func('123 456 789'), '321 654 987')\n",
" self.assertEqual(func('magic'), 'cigam')\n",
" print('Success: reverse_words')\n",
" \n",
"\n",
"\n",
"def main():\n",
" test = UnitTest()\n",
" test.testReverseWords(reverse_words)\n",
"\n",
"\n",
"if __name__==\"__main__\":\n",
" main()"
]
@ -129,23 +133,23 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"display_name": "Python 3",
"language": "python",
"name": "python2"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2.0
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
"pygments_lexer": "ipython3",
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}

View File

@ -66,29 +66,25 @@
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"def reverse_words(S):\n",
" if len(S) is 0:\n",
" return None\n",
" \n",
"\n",
" words = S.split()\n",
" for i in range (len(words)):\n",
" words[i] = words[i][::-1]\n",
" \n",
"\n",
" return \" \".join(words)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
@ -100,30 +96,32 @@
],
"source": [
"%%writefile reverse_words_solution.py\n",
"from nose.tools import assert_equal\n",
"import unittest\n",
"\n",
"\n",
"class TestReverseWords(unittest.TestCase):\n",
"\n",
"class UnitTest (object):\n",
" def testReverseWords(self, func):\n",
" assert_equal(func('the sun is hot'), 'eht nus si toh')\n",
" assert_equal(func(''), None)\n",
" assert_equal(func('123 456 789'), '321 654 987')\n",
" assert_equal(func('magic'), 'cigam')\n",
" self.assertEqual(func('the sun is hot'), 'eht nus si toh')\n",
" self.assertEqual(func(''), None)\n",
" self.assertEqual(func('123 456 789'), '321 654 987')\n",
" self.assertEqual(func('magic'), 'cigam')\n",
" print('Success: reverse_words')\n",
" \n",
"\n",
"\n",
"def main():\n",
" test = UnitTest()\n",
" test = TestReverseWords()\n",
" test.testReverseWords(reverse_words)\n",
"\n",
"\n",
"if __name__==\"__main__\":\n",
" main()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
@ -140,23 +138,23 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"display_name": "Python 3",
"language": "python",
"name": "python2"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
"pygments_lexer": "ipython3",
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}

View File

@ -1,16 +1,20 @@
from nose.tools import assert_equal
import unittest
class TestReverseWords(unittest.TestCase):
class UnitTest (object):
def testReverseWords(self, func):
assert_equal(func('the sun is hot'), 'eht nus si toh')
assert_equal(func(''), None)
assert_equal(func('123 456 789'), '321 654 987')
assert_equal(func('magic'), 'cigam')
self.assertEqual(func('the sun is hot'), 'eht nus si toh')
self.assertEqual(func(''), None)
self.assertEqual(func('123 456 789'), '321 654 987')
self.assertEqual(func('magic'), 'cigam')
print('Success: reverse_words')
def main():
test = UnitTest()
test = TestReverseWords()
test.testReverseWords(reverse_words)
if __name__=="__main__":
main()
main()

View File

@ -152,4 +152,4 @@ class BinaryTree (object):
return preOrder
def treeIsEmpty (self):
return self.root is None
return self.root is None

View File

@ -93,9 +93,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"class Node (object):\n",
@ -111,9 +109,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"class BinaryTree (object):\n",
@ -163,15 +159,13 @@
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from nose.tools import assert_equal\n",
"import unittest\n",
"\n",
"class TestBinaryTree(object):\n",
"class TestBinaryTree(unittest.TestCase):\n",
"\n",
"\tdef test_insert_traversals (self):\n",
"\t\tmyTree = BinaryTree()\n",
@ -182,22 +176,22 @@
"\n",
"\t\tprint(\"Test: insert checking with in order traversal\")\n",
"\t\texpectVal = [7, 10, 25, 30, 38, 40, 50, 60, 70, 80]\n",
"\t\tassert_equal(myTree.printInOrder(), expectVal)\n",
"\t\tself.assertEqual(myTree.printInOrder(), expectVal)\n",
"\t\texpectVal = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91]\n",
"\t\tassert_equal(myTree2.printInOrder(), expectVal)\n",
"\t\tself.assertEqual(myTree2.printInOrder(), expectVal)\n",
"\n",
"\t\tprint(\"Test: insert checking with post order traversal\")\n",
"\t\texpectVal = [7, 25, 10, 38, 40, 30, 60, 80, 70, 50]\n",
"\t\tassert_equal(myTree.printPostOrder(), expectVal)\n",
"\t\tself.assertEqual(myTree.printPostOrder(), expectVal)\n",
"\t\texpectVal = [91, 81, 71, 61, 51, 41, 31, 21, 11, 1]\n",
"\t\tassert_equal(myTree2.printPostOrder(), expectVal)\n",
"\t\tself.assertEqual(myTree2.printPostOrder(), expectVal)\n",
"\n",
"\n",
"\t\tprint(\"Test: insert checking with pre order traversal\")\n",
"\t\texpectVal = [50, 30, 10, 7, 25, 40, 38, 70, 60, 80]\n",
"\t\tassert_equal(myTree.printPreOrder(), expectVal)\n",
"\t\tself.assertEqual(myTree.printPreOrder(), expectVal)\n",
"\t\texpectVal = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91]\n",
"\t\tassert_equal(myTree2.printPreOrder(), expectVal)\n",
"\t\tself.assertEqual(myTree2.printPreOrder(), expectVal)\n",
"\n",
"\n",
"\t\tprint(\"Success: test_insert_traversals\")\n",
@ -209,16 +203,16 @@
"\t\tmyTree.insert(21)\n",
"\n",
"\t\tprint(\"Test: max node\")\n",
"\t\tassert_equal(myTree.maxNode(), 21)\n",
"\t\tself.assertEqual(myTree.maxNode(), 21)\n",
"\t\tmyTree.insert(32)\n",
"\t\tassert_equal(myTree.maxNode(), 32)\n",
"\t\tself.assertEqual(myTree.maxNode(), 32)\n",
"\n",
"\t\tprint(\"Test: min node\")\n",
"\t\tassert_equal(myTree.minNode(), 1)\n",
"\t\tself.assertEqual(myTree.minNode(), 1)\n",
"\n",
"\t\tprint(\"Test: min node inserting negative number\")\n",
"\t\tmyTree.insert(-10)\n",
"\t\tassert_equal(myTree.minNode(), -10)\n",
"\t\tself.assertEqual(myTree.minNode(), -10)\n",
"\n",
"\t\tprint(\"Success: test_max_min_nodes\")\n",
"\n",
@ -228,15 +222,15 @@
"\n",
"\t\tprint(\"Test: delete\")\n",
"\t\tmyTree.delete(5)\n",
"\t\tassert_equal(myTree.treeIsEmpty(), True)\n",
"\t\tself.assertEqual(myTree.treeIsEmpty(), True)\n",
"\t\t\n",
"\t\tprint(\"Test: more complex deletions\")\n",
"\t\t[myTree.insert(x) for x in range(1, 5)]\n",
"\t\tmyTree.delete(2)\n",
"\t\tassert_equal(myTree.root.rightChild.data, 3)\n",
"\t\tself.assertEqual(myTree.root.rightChild.data, 3)\n",
" \n",
"\t\tprint(\"Test: delete invalid value\")\n",
"\t\tassert_equal(myTree.delete(100), False)\n",
"\t\tself.assertEqual(myTree.delete(100), False)\n",
"\n",
"\n",
"\t\tprint(\"Success: test_delete\")\n",
@ -284,9 +278,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
}

View File

@ -169,10 +169,8 @@
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
@ -343,10 +341,8 @@
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"%run binary_search_tree.py"
@ -354,10 +350,8 @@
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
@ -369,9 +363,9 @@
],
"source": [
"%%writefile test_binary_search_tree.py\n",
"from nose.tools import assert_equal\n",
"import unittest\n",
"\n",
"class TestBinaryTree(object):\n",
"class TestBinaryTree(unittest.TestCase):\n",
"\n",
"\tdef test_insert_traversals (self):\n",
"\t\tmyTree = BinaryTree()\n",
@ -382,22 +376,22 @@
"\n",
"\t\tprint(\"Test: insert checking with in order traversal\")\n",
"\t\texpectVal = [7, 10, 25, 30, 38, 40, 50, 60, 70, 80]\n",
"\t\tassert_equal(myTree.printInOrder(), expectVal)\n",
"\t\tself.assertEqual(myTree.printInOrder(), expectVal)\n",
"\t\texpectVal = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91]\n",
"\t\tassert_equal(myTree2.printInOrder(), expectVal)\n",
"\t\tself.assertEqual(myTree2.printInOrder(), expectVal)\n",
"\n",
"\t\tprint(\"Test: insert checking with post order traversal\")\n",
"\t\texpectVal = [7, 25, 10, 38, 40, 30, 60, 80, 70, 50]\n",
"\t\tassert_equal(myTree.printPostOrder(), expectVal)\n",
"\t\tself.assertEqual(myTree.printPostOrder(), expectVal)\n",
"\t\texpectVal = [91, 81, 71, 61, 51, 41, 31, 21, 11, 1]\n",
"\t\tassert_equal(myTree2.printPostOrder(), expectVal)\n",
"\t\tself.assertEqual(myTree2.printPostOrder(), expectVal)\n",
"\n",
"\n",
"\t\tprint(\"Test: insert checking with pre order traversal\")\n",
"\t\texpectVal = [50, 30, 10, 7, 25, 40, 38, 70, 60, 80]\n",
"\t\tassert_equal(myTree.printPreOrder(), expectVal)\n",
"\t\tself.assertEqual(myTree.printPreOrder(), expectVal)\n",
"\t\texpectVal = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91]\n",
"\t\tassert_equal(myTree2.printPreOrder(), expectVal)\n",
"\t\tself.assertEqual(myTree2.printPreOrder(), expectVal)\n",
"\n",
"\n",
"\t\tprint(\"Success: test_insert_traversals\")\n",
@ -409,16 +403,16 @@
"\t\tmyTree.insert(21)\n",
"\n",
"\t\tprint(\"Test: max node\")\n",
"\t\tassert_equal(myTree.maxNode(), 21)\n",
"\t\tself.assertEqual(myTree.maxNode(), 21)\n",
"\t\tmyTree.insert(32)\n",
"\t\tassert_equal(myTree.maxNode(), 32)\n",
"\t\tself.assertEqual(myTree.maxNode(), 32)\n",
"\n",
"\t\tprint(\"Test: min node\")\n",
"\t\tassert_equal(myTree.minNode(), 1)\n",
"\t\tself.assertEqual(myTree.minNode(), 1)\n",
"\n",
"\t\tprint(\"Test: min node inserting negative number\")\n",
"\t\tmyTree.insert(-10)\n",
"\t\tassert_equal(myTree.minNode(), -10)\n",
"\t\tself.assertEqual(myTree.minNode(), -10)\n",
"\n",
"\t\tprint(\"Success: test_max_min_nodes\")\n",
"\n",
@ -428,15 +422,15 @@
"\n",
"\t\tprint(\"Test: delete\")\n",
"\t\tmyTree.delete(5)\n",
"\t\tassert_equal(myTree.treeIsEmpty(), True)\n",
"\t\tself.assertEqual(myTree.treeIsEmpty(), True)\n",
"\t\t\n",
"\t\tprint(\"Test: more complex deletions\")\n",
"\t\t[myTree.insert(x) for x in range(1, 5)]\n",
"\t\tmyTree.delete(2)\n",
"\t\tassert_equal(myTree.root.rightChild.data, 3)\n",
"\t\tself.assertEqual(myTree.root.rightChild.data, 3)\n",
" \n",
"\t\tprint(\"Test: delete invalid value\")\n",
"\t\tassert_equal(myTree.delete(100), False)\n",
"\t\tself.assertEqual(myTree.delete(100), False)\n",
"\n",
"\n",
"\t\tprint(\"Success: test_delete\")\n",
@ -453,10 +447,8 @@
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false
},
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
@ -498,9 +490,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
}

View File

@ -1,6 +1,6 @@
from nose.tools import assert_equal
import unittest
class TestBinaryTree(object):
class TestBinaryTree(unittest.TestCase):
def test_insert_traversals (self):
myTree = BinaryTree()
@ -11,22 +11,22 @@ class TestBinaryTree(object):
print("Test: insert checking with in order traversal")
expectVal = [7, 10, 25, 30, 38, 40, 50, 60, 70, 80]
assert_equal(myTree.printInOrder(), expectVal)
self.assertEqual(myTree.printInOrder(), expectVal)
expectVal = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91]
assert_equal(myTree2.printInOrder(), expectVal)
self.assertEqual(myTree2.printInOrder(), expectVal)
print("Test: insert checking with post order traversal")
expectVal = [7, 25, 10, 38, 40, 30, 60, 80, 70, 50]
assert_equal(myTree.printPostOrder(), expectVal)
self.assertEqual(myTree.printPostOrder(), expectVal)
expectVal = [91, 81, 71, 61, 51, 41, 31, 21, 11, 1]
assert_equal(myTree2.printPostOrder(), expectVal)
self.assertEqual(myTree2.printPostOrder(), expectVal)
print("Test: insert checking with pre order traversal")
expectVal = [50, 30, 10, 7, 25, 40, 38, 70, 60, 80]
assert_equal(myTree.printPreOrder(), expectVal)
self.assertEqual(myTree.printPreOrder(), expectVal)
expectVal = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91]
assert_equal(myTree2.printPreOrder(), expectVal)
self.assertEqual(myTree2.printPreOrder(), expectVal)
print("Success: test_insert_traversals")
@ -38,16 +38,16 @@ class TestBinaryTree(object):
myTree.insert(21)
print("Test: max node")
assert_equal(myTree.maxNode(), 21)
self.assertEqual(myTree.maxNode(), 21)
myTree.insert(32)
assert_equal(myTree.maxNode(), 32)
self.assertEqual(myTree.maxNode(), 32)
print("Test: min node")
assert_equal(myTree.minNode(), 1)
self.assertEqual(myTree.minNode(), 1)
print("Test: min node inserting negative number")
myTree.insert(-10)
assert_equal(myTree.minNode(), -10)
self.assertEqual(myTree.minNode(), -10)
print("Success: test_max_min_nodes")
@ -57,14 +57,15 @@ class TestBinaryTree(object):
print("Test: delete")
myTree.delete(5)
assert_equal(myTree.treeIsEmpty(), True)
self.assertEqual(myTree.treeIsEmpty(), True)
print("Test: more complex deletions")
[myTree.insert(x) for x in range(1, 5)]
myTree.delete(2)
assert_equal(myTree.root.rightChild.data, 3)
self.assertEqual(myTree.root.rightChild.data, 3)
print("Test: delete invalid value")
assert_equal(myTree.delete(100), False)
self.assertEqual(myTree.delete(100), False)
print("Success: test_delete")
@ -76,4 +77,4 @@ def main():
testing.test_delete()
if __name__=='__main__':
main()
main()

View File

@ -71,9 +71,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"def group_ordered(list_in):\n",
@ -98,28 +96,26 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"# %load test_group_ordered.py\n",
"from nose.tools import assert_equal\n",
"import unittest\n",
"\n",
"\n",
"class TestGroupOrdered(object):\n",
"class TestGroupOrdered(unittest.TestCase):\n",
" def test_group_ordered(self, func):\n",
"\n",
" assert_equal(func(None), None)\n",
" self.assertEqual(func(None), None)\n",
" print('Success: ' + func.__name__ + \" None case.\")\n",
" assert_equal(func([]), [])\n",
" self.assertEqual(func([]), [])\n",
" print('Success: ' + func.__name__ + \" Empty case.\")\n",
" assert_equal(func([1]), [1])\n",
" self.assertEqual(func([1]), [1])\n",
" print('Success: ' + func.__name__ + \" Single element case.\")\n",
" assert_equal(func([1, 2, 1, 3, 2]), [1, 1, 2, 2, 3])\n",
" assert_equal(func(['a', 'b', 'a']), ['a', 'a', 'b'])\n",
" assert_equal(func([1, 1, 2, 3, 4, 5, 2, 1]), [1, 1, 1, 2, 2, 3, 4, 5])\n",
" assert_equal(func([1, 2, 3, 4, 3, 4]), [1, 2, 3, 3, 4, 4])\n",
" self.assertEqual(func([1, 2, 1, 3, 2]), [1, 1, 2, 2, 3])\n",
" self.assertEqual(func(['a', 'b', 'a']), ['a', 'a', 'b'])\n",
" self.assertEqual(func([1, 1, 2, 3, 4, 5, 2, 1]), [1, 1, 1, 2, 2, 3, 4, 5])\n",
" self.assertEqual(func([1, 2, 3, 4, 3, 4]), [1, 2, 3, 3, 4, 4])\n",
" print('Success: ' + func.__name__)\n",
"\n",
"\n",
@ -149,23 +145,23 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"display_name": "Python 3",
"language": "python",
"name": "python2"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
"pygments_lexer": "ipython3",
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}

View File

@ -77,10 +77,8 @@
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"def make_order_list(list_in):\n",
@ -135,10 +133,8 @@
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true
},
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"from collections import OrderedDict\n",
@ -163,10 +159,8 @@
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
@ -178,22 +172,22 @@
],
"source": [
"%%writefile test_group_ordered.py\n",
"from nose.tools import assert_equal\n",
"import unittest\n",
"\n",
"\n",
"class TestGroupOrdered(object):\n",
"class TestGroupOrdered(unittest.TestCase):\n",
" def test_group_ordered(self, func):\n",
"\n",
" assert_equal(func(None), None)\n",
" self.assertEqual(func(None), None)\n",
" print('Success: ' + func.__name__ + \" None case.\")\n",
" assert_equal(func([]), [])\n",
" self.assertEqual(func([]), [])\n",
" print('Success: ' + func.__name__ + \" Empty case.\")\n",
" assert_equal(func([1]), [1])\n",
" self.assertEqual(func([1]), [1])\n",
" print('Success: ' + func.__name__ + \" Single element case.\")\n",
" assert_equal(func([1, 2, 1, 3, 2]), [1, 1, 2, 2, 3])\n",
" assert_equal(func(['a', 'b', 'a']), ['a', 'a', 'b'])\n",
" assert_equal(func([1, 1, 2, 3, 4, 5, 2, 1]), [1, 1, 1, 2, 2, 3, 4, 5])\n",
" assert_equal(func([1, 2, 3, 4, 3, 4]), [1, 2, 3, 3, 4, 4])\n",
" self.assertEqual(func([1, 2, 1, 3, 2]), [1, 1, 2, 2, 3])\n",
" self.assertEqual(func(['a', 'b', 'a']), ['a', 'a', 'b'])\n",
" self.assertEqual(func([1, 1, 2, 3, 4, 5, 2, 1]), [1, 1, 1, 2, 2, 3, 4, 5])\n",
" self.assertEqual(func([1, 2, 3, 4, 3, 4]), [1, 2, 3, 3, 4, 4])\n",
" print('Success: ' + func.__name__)\n",
"\n",
"\n",
@ -213,10 +207,8 @@
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
@ -240,23 +232,23 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"display_name": "Python 3",
"language": "python",
"name": "python2"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
"pygments_lexer": "ipython3",
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}

View File

@ -1,19 +1,19 @@
from nose.tools import assert_equal
import unittest
class TestGroupOrdered(object):
class TestGroupOrdered(unittest.TestCase):
def test_group_ordered(self, func):
assert_equal(func(None), None)
self.assertEqual(func(None), None)
print('Success: ' + func.__name__ + " None case.")
assert_equal(func([]), [])
self.assertEqual(func([]), [])
print('Success: ' + func.__name__ + " Empty case.")
assert_equal(func([1]), [1])
self.assertEqual(func([1]), [1])
print('Success: ' + func.__name__ + " Single element case.")
assert_equal(func([1, 2, 1, 3, 2]), [1, 1, 2, 2, 3])
assert_equal(func(['a', 'b', 'a']), ['a', 'a', 'b'])
assert_equal(func([1, 1, 2, 3, 4, 5, 2, 1]), [1, 1, 1, 2, 2, 3, 4, 5])
assert_equal(func([1, 2, 3, 4, 3, 4]), [1, 2, 3, 3, 4, 4])
self.assertEqual(func([1, 2, 1, 3, 2]), [1, 1, 2, 2, 3])
self.assertEqual(func(['a', 'b', 'a']), ['a', 'a', 'b'])
self.assertEqual(func([1, 1, 2, 3, 4, 5, 2, 1]), [1, 1, 1, 2, 2, 3, 4, 5])
self.assertEqual(func([1, 2, 3, 4, 3, 4]), [1, 2, 3, 3, 4, 4])
print('Success: ' + func.__name__)
@ -28,4 +28,4 @@ def main():
pass
if __name__ == '__main__':
main()
main()