Changed discussions of NULL to None to be more Pythonic.

This commit is contained in:
Donne Martin
2015-07-06 05:44:06 -04:00
parent 29685c7b35
commit 47e6a23dde
11 changed files with 55 additions and 55 deletions

View File

@@ -2,14 +2,14 @@ from nose.tools import assert_equal
class TestLinkedList(object):
def test_insert_to_front(self):
print('Test: insert_to_front on an empty list')
linked_list = LinkedList(None)
linked_list.insert_to_front(10)
assert_equal(linked_list.get_all_data(), [10])
print('Test: insert_to_front on a NULL')
print('Test: insert_to_front on a None')
linked_list.insert_to_front(None)
assert_equal(linked_list.get_all_data(), [10])
@@ -17,16 +17,16 @@ class TestLinkedList(object):
linked_list.insert_to_front('a')
linked_list.insert_to_front('bc')
assert_equal(linked_list.get_all_data(), ['bc', 'a', 10])
print('Success: test_insert_to_front\n')
def test_append(self):
print('Test: append on an empty list')
linked_list = LinkedList(None)
linked_list.append(10)
assert_equal(linked_list.get_all_data(), [10])
print('Test: append a NULL')
print('Test: append a None')
linked_list.append(None)
assert_equal(linked_list.get_all_data(), [10])
@@ -34,16 +34,16 @@ class TestLinkedList(object):
linked_list.append('a')
linked_list.append('bc')
assert_equal(linked_list.get_all_data(), [10, 'a', 'bc'])
print('Success: test_append\n')
def test_find(self):
print('Test: find on an empty list')
linked_list = LinkedList(None)
node = linked_list.find('a')
assert_equal(node, None)
print('Test: find a NULL')
print('Test: find a None')
head = Node(10)
linked_list = LinkedList(head)
node = linked_list.find(None)
@@ -60,16 +60,16 @@ class TestLinkedList(object):
print('Test: find general case with no matches')
node = linked_list.find('aaa')
assert_equal(node, None)
print('Success: test_find\n')
def test_delete(self):
print('Test: delete on an empty list')
linked_list = LinkedList(None)
linked_list.delete('a')
assert_equal(linked_list.get_all_data(), [])
print('Test: delete a NULL')
print('Test: delete a None')
head = Node(10)
linked_list = LinkedList(head)
linked_list.delete(None)
@@ -86,9 +86,9 @@ class TestLinkedList(object):
print('Test: delete general case with no matches')
linked_list.delete('aa')
assert_equal(linked_list.get_all_data(), ['bc', 10])
print('Success: test_delete\n')
def test_len(self):
print('Test: len on an empty list')
linked_list = LinkedList(None)
@@ -100,7 +100,7 @@ class TestLinkedList(object):
linked_list.insert_to_front('a')
linked_list.insert_to_front('bc')
assert_equal(len(linked_list), 3)
print('Success: test_len\n')
def main():
@@ -110,6 +110,6 @@ def main():
test.test_find()
test.test_delete()
test.test_len()
if __name__ == '__main__':
main()