def test_cursor_assignment_does_not_exceed_bounds(self): """ testing that cursors don't overlap or exceed bounds """ f = File() f.file_lines = ['line: ' + str(i) for i in range(0, 10)] f.cursor_end = 20 f.cursor_start = 15 self.assertEqual( f.file_length - 1, f.cursor_end, msg='End cursor should match file length when bounds exceed') self.assertEqual( f.cursor_end, f.cursor_start, msg='start cursor should match end cursor when start overlaps') f.cursor_start = -10 f.cursor_end = -5 self.assertEqual( f.cursor_start, 0, msg='End cursor should match file length when bounds exceed') self.assertEqual( f.cursor_end, f.cursor_start, msg='end cursor should match start cursor when end overlaps') f.cursor_end = 4 f.cursor_start = 2 f.cursor_end = 1 self.assertEqual( f.cursor_end, f.cursor_start, msg='end cursor should match start cursor when end overlaps')
def test_cursor_assignment_via_setter_property_works(self): """ test the cursor assignment functions correctly """ f = File() f.cursor_start = 1 f.cursor_end = 1 f.file_length = 20 self.assertEqual(f.cursor_start, 0, msg='Zero Lines, cursor should reset to 0') self.assertEqual(f.cursor_end, 0, msg='Zero Lines, cursor should reset to 0') f.file_lines = ['line: ' + str(i) for i in range(0, 10)] self.assertEqual(f.file_length, 10, msg='Ten Lines, length should be 0')