From b9c15ef8e3ad5d5a3bbcbe1de22a5b7ec7789c92 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 16 Oct 2016 20:47:00 +0530 Subject: [PATCH] Tests for Cursor --- kitty/data_types.py | 12 ++++++++++++ kitty_tests/datatypes.py | 13 ++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/kitty/data_types.py b/kitty/data_types.py index 1c490ea66..9f06e2396 100644 --- a/kitty/data_types.py +++ b/kitty/data_types.py @@ -40,8 +40,20 @@ class Cursor: ans.hidden = self.hidden ans.fg, ans.bg, ans.decoration_fg = self.fg, self.bg, self.decoration_fg ans.bold, ans.italic, ans.reverse, ans.strikethrough = self.bold, self.italic, self.reverse, self.strikethrough + ans.decoration = self.decoration return ans + def __eq__(self, other): + if not isinstance(other, Cursor): + return False + for x in self.__slots__: + if getattr(self, x) != getattr(other, x): + return False + return True + + def __ne__(self, other): + return not self.__eq__(other) + class Line: diff --git a/kitty_tests/datatypes.py b/kitty_tests/datatypes.py index 30900cac0..a27168a14 100644 --- a/kitty_tests/datatypes.py +++ b/kitty_tests/datatypes.py @@ -4,7 +4,7 @@ from . import BaseTest, set_text_in_line -from kitty.data_types import Line +from kitty.data_types import Line, Cursor class TestDataTypes(BaseTest): @@ -13,6 +13,7 @@ class TestDataTypes(BaseTest): t = 'Testing with simple text' l = Line(len(t)) set_text_in_line(l, t) + self.ae(l, l) self.ae(str(l), t) self.ae(str(l.copy()), t) l.continued = False @@ -21,3 +22,13 @@ class TestDataTypes(BaseTest): self.ae(l, l2) l2.char[1] = 23 self.assertNotEqual(l, l2) + + c = Cursor(3, 5) + c.hidden = True + c.bold = c.italic = c.reverse = c.strikethrough = True + c.fg = c.bg = c.decoration_fg = 0x0101 + self.ae(c, c) + c2 = c.copy() + self.ae(c, c.copy()) + c2.bold = False + self.assertNotEqual(c, c2)