Skip to content

Commit

Permalink
#273: Remove nose dependency for linked_lists/
Browse files Browse the repository at this point in the history
  • Loading branch information
donnemartin committed Jul 5, 2020
1 parent b598f47 commit 8f93399
Show file tree
Hide file tree
Showing 25 changed files with 283 additions and 383 deletions.
26 changes: 11 additions & 15 deletions linked_lists/add_reverse/add_reverse_challenge.ipynb
Expand Up @@ -95,9 +95,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class MyLinkedList(LinkedList):\n",
Expand Down Expand Up @@ -126,22 +124,20 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"# %load test_add_reverse.py\n",
"from nose.tools import assert_equal\n",
"import unittest\n",
"\n",
"\n",
"class TestAddReverse(object):\n",
"class TestAddReverse(unittest.TestCase):\n",
"\n",
" def test_add_reverse(self):\n",
" print('Test: Empty list(s)')\n",
" assert_equal(MyLinkedList().add_reverse(None, None), None)\n",
" assert_equal(MyLinkedList().add_reverse(Node(5), None), None)\n",
" assert_equal(MyLinkedList().add_reverse(None, Node(10)), None)\n",
" self.assertEqual(MyLinkedList().add_reverse(None, None), None)\n",
" self.assertEqual(MyLinkedList().add_reverse(Node(5), None), None)\n",
" self.assertEqual(MyLinkedList().add_reverse(None, Node(10)), None)\n",
"\n",
" print('Test: Add values of different lengths')\n",
" # Input 1: 6->5->None\n",
Expand All @@ -153,7 +149,7 @@
" second_list.append(8)\n",
" second_list.append(7)\n",
" result = MyLinkedList().add_reverse(first_list, second_list)\n",
" assert_equal(result.get_all_data(), [5, 4, 8])\n",
" self.assertEqual(result.get_all_data(), [5, 4, 8])\n",
"\n",
" print('Test: Add values of same lengths')\n",
" # Input 1: 6->5->4\n",
Expand All @@ -168,7 +164,7 @@
" second_list.append(8)\n",
" second_list.append(7)\n",
" result = MyLinkedList().add_reverse(first_list, second_list)\n",
" assert_equal(result.get_all_data(), [5, 4, 2, 1])\n",
" self.assertEqual(result.get_all_data(), [5, 4, 2, 1])\n",
"\n",
" print('Success: test_add_reverse')\n",
"\n",
Expand Down Expand Up @@ -208,9 +204,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
}
34 changes: 13 additions & 21 deletions linked_lists/add_reverse/add_reverse_solution.ipynb
Expand Up @@ -103,9 +103,7 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"%run ../linked_list/linked_list.py"
Expand All @@ -114,9 +112,7 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class MyLinkedList(LinkedList):\n",
Expand Down Expand Up @@ -157,9 +153,7 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand All @@ -171,16 +165,16 @@
],
"source": [
"%%writefile test_add_reverse.py\n",
"from nose.tools import assert_equal\n",
"import unittest\n",
"\n",
"\n",
"class TestAddReverse(object):\n",
"class TestAddReverse(unittest.TestCase):\n",
"\n",
" def test_add_reverse(self):\n",
" print('Test: Empty list(s)')\n",
" assert_equal(MyLinkedList().add_reverse(None, None), None)\n",
" assert_equal(MyLinkedList().add_reverse(Node(5), None), None)\n",
" assert_equal(MyLinkedList().add_reverse(None, Node(10)), None)\n",
" self.assertEqual(MyLinkedList().add_reverse(None, None), None)\n",
" self.assertEqual(MyLinkedList().add_reverse(Node(5), None), None)\n",
" self.assertEqual(MyLinkedList().add_reverse(None, Node(10)), None)\n",
"\n",
" print('Test: Add values of different lengths')\n",
" # Input 1: 6->5->None\n",
Expand All @@ -192,7 +186,7 @@
" second_list.append(8)\n",
" second_list.append(7)\n",
" result = MyLinkedList().add_reverse(first_list, second_list)\n",
" assert_equal(result.get_all_data(), [5, 4, 8])\n",
" self.assertEqual(result.get_all_data(), [5, 4, 8])\n",
"\n",
" print('Test: Add values of same lengths')\n",
" # Input 1: 6->5->4\n",
Expand All @@ -207,7 +201,7 @@
" second_list.append(8)\n",
" second_list.append(7)\n",
" result = MyLinkedList().add_reverse(first_list, second_list)\n",
" assert_equal(result.get_all_data(), [5, 4, 2, 1])\n",
" self.assertEqual(result.get_all_data(), [5, 4, 2, 1])\n",
"\n",
" print('Success: test_add_reverse')\n",
"\n",
Expand All @@ -224,9 +218,7 @@
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -260,9 +252,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
}
16 changes: 8 additions & 8 deletions linked_lists/add_reverse/test_add_reverse.py
@@ -1,13 +1,13 @@
from nose.tools import assert_equal
import unittest


class TestAddReverse(object):
class TestAddReverse(unittest.TestCase):

def test_add_reverse(self):
print('Test: Empty list(s)')
assert_equal(MyLinkedList().add_reverse(None, None), None)
assert_equal(MyLinkedList().add_reverse(Node(5), None), None)
assert_equal(MyLinkedList().add_reverse(None, Node(10)), None)
self.assertEqual(MyLinkedList().add_reverse(None, None), None)
self.assertEqual(MyLinkedList().add_reverse(Node(5), None), None)
self.assertEqual(MyLinkedList().add_reverse(None, Node(10)), None)

print('Test: Add values of different lengths')
# Input 1: 6->5->None
Expand All @@ -19,7 +19,7 @@ def test_add_reverse(self):
second_list.append(8)
second_list.append(7)
result = MyLinkedList().add_reverse(first_list, second_list)
assert_equal(result.get_all_data(), [5, 4, 8])
self.assertEqual(result.get_all_data(), [5, 4, 8])

print('Test: Add values of same lengths')
# Input 1: 6->5->4
Expand All @@ -34,7 +34,7 @@ def test_add_reverse(self):
second_list.append(8)
second_list.append(7)
result = MyLinkedList().add_reverse(first_list, second_list)
assert_equal(result.get_all_data(), [5, 4, 2, 1])
self.assertEqual(result.get_all_data(), [5, 4, 2, 1])

print('Success: test_add_reverse')

Expand All @@ -45,4 +45,4 @@ def main():


if __name__ == '__main__':
main()
main()
28 changes: 11 additions & 17 deletions linked_lists/delete_mid/delete_mid_challenge.ipynb
Expand Up @@ -73,9 +73,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"%run ../linked_list/linked_list.py\n",
Expand All @@ -85,9 +83,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class MyLinkedList(LinkedList):\n",
Expand Down Expand Up @@ -116,28 +112,26 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"# %load test_delete_mid.py\n",
"from nose.tools import assert_equal\n",
"import unittest\n",
"\n",
"\n",
"class TestDeleteNode(object):\n",
"class TestDeleteNode(unittest.TestCase):\n",
"\n",
" def test_delete_node(self):\n",
" print('Test: Empty list, null node to delete')\n",
" linked_list = MyLinkedList(None)\n",
" linked_list.delete_node(None)\n",
" assert_equal(linked_list.get_all_data(), [])\n",
" self.assertEqual(linked_list.get_all_data(), [])\n",
"\n",
" print('Test: One node')\n",
" head = Node(2)\n",
" linked_list = MyLinkedList(head)\n",
" linked_list.delete_node(head)\n",
" assert_equal(linked_list.get_all_data(), [None])\n",
" self.assertEqual(linked_list.get_all_data(), [None])\n",
"\n",
" print('Test: Multiple nodes')\n",
" linked_list = MyLinkedList(None)\n",
Expand All @@ -146,7 +140,7 @@
" node2 = linked_list.insert_to_front(4)\n",
" node3 = linked_list.insert_to_front(1)\n",
" linked_list.delete_node(node1)\n",
" assert_equal(linked_list.get_all_data(), [1, 4, 2])\n",
" self.assertEqual(linked_list.get_all_data(), [1, 4, 2])\n",
"\n",
" print('Test: Multiple nodes, delete last element')\n",
" linked_list = MyLinkedList(None)\n",
Expand All @@ -155,7 +149,7 @@
" node2 = linked_list.insert_to_front(4)\n",
" node3 = linked_list.insert_to_front(1)\n",
" linked_list.delete_node(node0)\n",
" assert_equal(linked_list.get_all_data(), [1, 4, 3, None])\n",
" self.assertEqual(linked_list.get_all_data(), [1, 4, 3, None])\n",
"\n",
" print('Success: test_delete_node')\n",
"\n",
Expand Down Expand Up @@ -195,9 +189,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
}
32 changes: 12 additions & 20 deletions linked_lists/delete_mid/delete_mid_solution.ipynb
Expand Up @@ -79,9 +79,7 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"%run ../linked_list/linked_list.py"
Expand All @@ -90,9 +88,7 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class MyLinkedList(LinkedList):\n",
Expand All @@ -117,9 +113,7 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand All @@ -131,22 +125,22 @@
],
"source": [
"%%writefile test_delete_mid.py\n",
"from nose.tools import assert_equal\n",
"import unittest\n",
"\n",
"\n",
"class TestDeleteNode(object):\n",
"class TestDeleteNode(unittest.TestCase):\n",
"\n",
" def test_delete_node(self):\n",
" print('Test: Empty list, null node to delete')\n",
" linked_list = MyLinkedList(None)\n",
" linked_list.delete_node(None)\n",
" assert_equal(linked_list.get_all_data(), [])\n",
" self.assertEqual(linked_list.get_all_data(), [])\n",
"\n",
" print('Test: One node')\n",
" head = Node(2)\n",
" linked_list = MyLinkedList(head)\n",
" linked_list.delete_node(head)\n",
" assert_equal(linked_list.get_all_data(), [None])\n",
" self.assertEqual(linked_list.get_all_data(), [None])\n",
"\n",
" print('Test: Multiple nodes')\n",
" linked_list = MyLinkedList(None)\n",
Expand All @@ -155,7 +149,7 @@
" node2 = linked_list.insert_to_front(4)\n",
" node3 = linked_list.insert_to_front(1)\n",
" linked_list.delete_node(node1)\n",
" assert_equal(linked_list.get_all_data(), [1, 4, 2])\n",
" self.assertEqual(linked_list.get_all_data(), [1, 4, 2])\n",
"\n",
" print('Test: Multiple nodes, delete last element')\n",
" linked_list = MyLinkedList(None)\n",
Expand All @@ -164,7 +158,7 @@
" node2 = linked_list.insert_to_front(4)\n",
" node3 = linked_list.insert_to_front(1)\n",
" linked_list.delete_node(node0)\n",
" assert_equal(linked_list.get_all_data(), [1, 4, 3, None])\n",
" self.assertEqual(linked_list.get_all_data(), [1, 4, 3, None])\n",
"\n",
" print('Success: test_delete_node')\n",
"\n",
Expand All @@ -181,9 +175,7 @@
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -218,9 +210,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
}

0 comments on commit 8f93399

Please sign in to comment.