mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-09 19:08:02 +00:00
@@ -89,9 +89,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class MyLinkedList(LinkedList):\n",
|
||||
@@ -120,26 +118,24 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# %load test_remove_duplicates.py\n",
|
||||
"from nose.tools import assert_equal\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestRemoveDupes(object):\n",
|
||||
"class TestRemoveDupes(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_remove_dupes(self, linked_list):\n",
|
||||
" print('Test: Empty list')\n",
|
||||
" linked_list.remove_dupes()\n",
|
||||
" assert_equal(linked_list.get_all_data(), [])\n",
|
||||
" self.assertEqual(linked_list.get_all_data(), [])\n",
|
||||
"\n",
|
||||
" print('Test: One element list')\n",
|
||||
" linked_list.insert_to_front(2)\n",
|
||||
" linked_list.remove_dupes()\n",
|
||||
" assert_equal(linked_list.get_all_data(), [2])\n",
|
||||
" self.assertEqual(linked_list.get_all_data(), [2])\n",
|
||||
"\n",
|
||||
" print('Test: General case, duplicates')\n",
|
||||
" linked_list.insert_to_front(1)\n",
|
||||
@@ -150,11 +146,11 @@
|
||||
" linked_list.insert_to_front(1)\n",
|
||||
" linked_list.insert_to_front(1)\n",
|
||||
" linked_list.remove_dupes()\n",
|
||||
" assert_equal(linked_list.get_all_data(), [1, 3, 2])\n",
|
||||
" self.assertEqual(linked_list.get_all_data(), [1, 3, 2])\n",
|
||||
"\n",
|
||||
" print('Test: General case, no duplicates')\n",
|
||||
" linked_list.remove_dupes()\n",
|
||||
" assert_equal(linked_list.get_all_data(), [1, 3, 2])\n",
|
||||
" self.assertEqual(linked_list.get_all_data(), [1, 3, 2])\n",
|
||||
"\n",
|
||||
" print('Success: test_remove_dupes\\n')\n",
|
||||
"\n",
|
||||
@@ -195,9 +191,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
|
||||
}
|
||||
|
||||
@@ -105,9 +105,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%run ../linked_list/linked_list.py"
|
||||
@@ -116,9 +114,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class MyLinkedList(LinkedList):\n",
|
||||
@@ -171,9 +167,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -185,20 +179,20 @@
|
||||
],
|
||||
"source": [
|
||||
"%%writefile test_remove_duplicates.py\n",
|
||||
"from nose.tools import assert_equal\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestRemoveDupes(object):\n",
|
||||
"class TestRemoveDupes(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_remove_dupes(self, linked_list):\n",
|
||||
" print('Test: Empty list')\n",
|
||||
" linked_list.remove_dupes()\n",
|
||||
" assert_equal(linked_list.get_all_data(), [])\n",
|
||||
" self.assertEqual(linked_list.get_all_data(), [])\n",
|
||||
"\n",
|
||||
" print('Test: One element list')\n",
|
||||
" linked_list.insert_to_front(2)\n",
|
||||
" linked_list.remove_dupes()\n",
|
||||
" assert_equal(linked_list.get_all_data(), [2])\n",
|
||||
" self.assertEqual(linked_list.get_all_data(), [2])\n",
|
||||
"\n",
|
||||
" print('Test: General case, duplicates')\n",
|
||||
" linked_list.insert_to_front(1)\n",
|
||||
@@ -209,11 +203,11 @@
|
||||
" linked_list.insert_to_front(1)\n",
|
||||
" linked_list.insert_to_front(1)\n",
|
||||
" linked_list.remove_dupes()\n",
|
||||
" assert_equal(linked_list.get_all_data(), [1, 3, 2])\n",
|
||||
" self.assertEqual(linked_list.get_all_data(), [1, 3, 2])\n",
|
||||
"\n",
|
||||
" print('Test: General case, no duplicates')\n",
|
||||
" linked_list.remove_dupes()\n",
|
||||
" assert_equal(linked_list.get_all_data(), [1, 3, 2])\n",
|
||||
" self.assertEqual(linked_list.get_all_data(), [1, 3, 2])\n",
|
||||
"\n",
|
||||
" print('Success: test_remove_dupes\\n')\n",
|
||||
"\n",
|
||||
@@ -231,9 +225,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -269,9 +261,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
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
from nose.tools import assert_equal
|
||||
import unittest
|
||||
|
||||
|
||||
class TestRemoveDupes(object):
|
||||
class TestRemoveDupes(unittest.TestCase):
|
||||
|
||||
def test_remove_dupes(self, linked_list):
|
||||
print('Test: Empty list')
|
||||
linked_list.remove_dupes()
|
||||
assert_equal(linked_list.get_all_data(), [])
|
||||
self.assertEqual(linked_list.get_all_data(), [])
|
||||
|
||||
print('Test: One element list')
|
||||
linked_list.insert_to_front(2)
|
||||
linked_list.remove_dupes()
|
||||
assert_equal(linked_list.get_all_data(), [2])
|
||||
self.assertEqual(linked_list.get_all_data(), [2])
|
||||
|
||||
print('Test: General case, duplicates')
|
||||
linked_list.insert_to_front(1)
|
||||
@@ -22,11 +22,11 @@ class TestRemoveDupes(object):
|
||||
linked_list.insert_to_front(1)
|
||||
linked_list.insert_to_front(1)
|
||||
linked_list.remove_dupes()
|
||||
assert_equal(linked_list.get_all_data(), [1, 3, 2])
|
||||
self.assertEqual(linked_list.get_all_data(), [1, 3, 2])
|
||||
|
||||
print('Test: General case, no duplicates')
|
||||
linked_list.remove_dupes()
|
||||
assert_equal(linked_list.get_all_data(), [1, 3, 2])
|
||||
self.assertEqual(linked_list.get_all_data(), [1, 3, 2])
|
||||
|
||||
print('Success: test_remove_dupes\n')
|
||||
|
||||
@@ -38,4 +38,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user