#273: Remove nose dependency for linked_lists/ (#275)

This commit is contained in:
Donne Martin
2020-07-06 21:09:04 -04:00
committed by GitHub
parent b598f474af
commit 0e7ed80228
25 changed files with 283 additions and 383 deletions

View File

@@ -88,9 +88,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class MyLinkedList(LinkedList):\n",
@@ -119,34 +117,32 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"# %load test_find_loop_start.py\n",
"from nose.tools import assert_equal\n",
"import unittest\n",
"\n",
"\n",
"class TestFindLoopStart(object):\n",
"class TestFindLoopStart(unittest.TestCase):\n",
"\n",
" def test_find_loop_start(self):\n",
" print('Test: Empty list')\n",
" linked_list = MyLinkedList()\n",
" assert_equal(linked_list.find_loop_start(), None)\n",
" self.assertEqual(linked_list.find_loop_start(), None)\n",
"\n",
" print('Test: Not a circular linked list: One element')\n",
" head = Node(1)\n",
" linked_list = MyLinkedList(head)\n",
" assert_equal(linked_list.find_loop_start(), None)\n",
" self.assertEqual(linked_list.find_loop_start(), None)\n",
"\n",
" print('Test: Not a circular linked list: Two elements')\n",
" linked_list.append(2)\n",
" assert_equal(linked_list.find_loop_start(), None)\n",
" self.assertEqual(linked_list.find_loop_start(), None)\n",
"\n",
" print('Test: Not a circular linked list: Three or more elements')\n",
" linked_list.append(3)\n",
" assert_equal(linked_list.find_loop_start(), None)\n",
" self.assertEqual(linked_list.find_loop_start(), None)\n",
"\n",
" print('Test: General case: Circular linked list')\n",
" node10 = Node(10)\n",
@@ -162,7 +158,7 @@
" node0 = Node(0, node1)\n",
" node10.next = node3\n",
" linked_list = MyLinkedList(node0)\n",
" assert_equal(linked_list.find_loop_start(), node3)\n",
" self.assertEqual(linked_list.find_loop_start(), node3)\n",
"\n",
" print('Success: test_find_loop_start')\n",
"\n",
@@ -202,9 +198,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
}

View File

@@ -85,9 +85,7 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"%run ../linked_list/linked_list.py"
@@ -96,9 +94,7 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class MyLinkedList(LinkedList):\n",
@@ -134,9 +130,7 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@@ -148,28 +142,28 @@
],
"source": [
"%%writefile test_find_loop_start.py\n",
"from nose.tools import assert_equal\n",
"import unittest\n",
"\n",
"\n",
"class TestFindLoopStart(object):\n",
"class TestFindLoopStart(unittest.TestCase):\n",
"\n",
" def test_find_loop_start(self):\n",
" print('Test: Empty list')\n",
" linked_list = MyLinkedList()\n",
" assert_equal(linked_list.find_loop_start(), None)\n",
" self.assertEqual(linked_list.find_loop_start(), None)\n",
"\n",
" print('Test: Not a circular linked list: One element')\n",
" head = Node(1)\n",
" linked_list = MyLinkedList(head)\n",
" assert_equal(linked_list.find_loop_start(), None)\n",
" self.assertEqual(linked_list.find_loop_start(), None)\n",
"\n",
" print('Test: Not a circular linked list: Two elements')\n",
" linked_list.append(2)\n",
" assert_equal(linked_list.find_loop_start(), None)\n",
" self.assertEqual(linked_list.find_loop_start(), None)\n",
"\n",
" print('Test: Not a circular linked list: Three or more elements')\n",
" linked_list.append(3)\n",
" assert_equal(linked_list.find_loop_start(), None)\n",
" self.assertEqual(linked_list.find_loop_start(), None)\n",
"\n",
" print('Test: General case: Circular linked list')\n",
" node10 = Node(10)\n",
@@ -185,7 +179,7 @@
" node0 = Node(0, node1)\n",
" node10.next = node3\n",
" linked_list = MyLinkedList(node0)\n",
" assert_equal(linked_list.find_loop_start(), node3)\n",
" self.assertEqual(linked_list.find_loop_start(), node3)\n",
"\n",
" print('Success: test_find_loop_start')\n",
"\n",
@@ -203,7 +197,6 @@
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
@@ -241,9 +234,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
}

View File

@@ -1,25 +1,25 @@
from nose.tools import assert_equal
import unittest
class TestFindLoopStart(object):
class TestFindLoopStart(unittest.TestCase):
def test_find_loop_start(self):
print('Test: Empty list')
linked_list = MyLinkedList()
assert_equal(linked_list.find_loop_start(), None)
self.assertEqual(linked_list.find_loop_start(), None)
print('Test: Not a circular linked list: One element')
head = Node(1)
linked_list = MyLinkedList(head)
assert_equal(linked_list.find_loop_start(), None)
self.assertEqual(linked_list.find_loop_start(), None)
print('Test: Not a circular linked list: Two elements')
linked_list.append(2)
assert_equal(linked_list.find_loop_start(), None)
self.assertEqual(linked_list.find_loop_start(), None)
print('Test: Not a circular linked list: Three or more elements')
linked_list.append(3)
assert_equal(linked_list.find_loop_start(), None)
self.assertEqual(linked_list.find_loop_start(), None)
print('Test: General case: Circular linked list')
node10 = Node(10)
@@ -35,7 +35,7 @@ class TestFindLoopStart(object):
node0 = Node(0, node1)
node10.next = node3
linked_list = MyLinkedList(node0)
assert_equal(linked_list.find_loop_start(), node3)
self.assertEqual(linked_list.find_loop_start(), node3)
print('Success: test_find_loop_start')
@@ -46,4 +46,4 @@ def main():
if __name__ == '__main__':
main()
main()