#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

@@ -1,21 +1,21 @@
from nose.tools import assert_equal
import unittest
class TestPalindrome(object):
class TestPalindrome(unittest.TestCase):
def test_palindrome(self):
print('Test: Empty list')
linked_list = MyLinkedList()
assert_equal(linked_list.is_palindrome(), False)
self.assertEqual(linked_list.is_palindrome(), False)
print('Test: Single element list')
head = Node(1)
linked_list = MyLinkedList(head)
assert_equal(linked_list.is_palindrome(), False)
self.assertEqual(linked_list.is_palindrome(), False)
print('Test: Two element list, not a palindrome')
linked_list.append(2)
assert_equal(linked_list.is_palindrome(), False)
self.assertEqual(linked_list.is_palindrome(), False)
print('Test: General case: Palindrome with even length')
head = Node('a')
@@ -23,7 +23,7 @@ class TestPalindrome(object):
linked_list.append('b')
linked_list.append('b')
linked_list.append('a')
assert_equal(linked_list.is_palindrome(), True)
self.assertEqual(linked_list.is_palindrome(), True)
print('Test: General case: Palindrome with odd length')
head = Node(1)
@@ -32,7 +32,7 @@ class TestPalindrome(object):
linked_list.append(3)
linked_list.append(2)
linked_list.append(1)
assert_equal(linked_list.is_palindrome(), True)
self.assertEqual(linked_list.is_palindrome(), True)
print('Success: test_palindrome')
@@ -43,4 +43,4 @@ def main():
if __name__ == '__main__':
main()
main()