forked from AllAlgorithms/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_node.py
More file actions
29 lines (21 loc) · 723 Bytes
/
Copy pathtest_node.py
File metadata and controls
29 lines (21 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import unittest
from node import Node
class TestNode(unittest.TestCase):
def setUp(self):
self.next_node = Node('item 2')
self.node = Node('item 1',self.next_node)
def test_str(self):
self.assertEqual(str(self.node),'[item 1] -> [item 2]')
def test_get_item(self):
self.assertEqual(self.node.get_item(),'item 1')
def test_get_next(self):
self.assertIs(self.node.get_next(),self.next_node)
def test_set_item(self):
self.node.set_item('another item')
self.assertEqual(self.node.get_item(),'another item')
def test_set_next(self):
another_node = Node('another item')
self.node.set_next(another_node)
self.assertIs(self.node.get_next(),another_node)
if __name__ == '__main__':
unittest.main()