mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-18 14:34:52 +02:00
Framework for testing
This commit is contained in:
20
kitty_tests/__init__.py
Normal file
20
kitty_tests/__init__.py
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
from unittest import TestCase
|
||||
|
||||
|
||||
class BaseTest(TestCase):
|
||||
|
||||
ae = TestCase.assertEqual
|
||||
|
||||
|
||||
def set_text_in_line(line, text, offset=0):
|
||||
pos = offset
|
||||
for ch in text:
|
||||
line.char[pos] = ord(ch)
|
||||
line.width[pos] = 1
|
||||
pos += 1
|
||||
if pos >= len(line):
|
||||
break
|
||||
23
kitty_tests/datatypes.py
Normal file
23
kitty_tests/datatypes.py
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
from . import BaseTest, set_text_in_line
|
||||
|
||||
from kitty.data_types import Line
|
||||
|
||||
|
||||
class TestDataTypes(BaseTest):
|
||||
|
||||
def test_line_ops(self):
|
||||
t = 'Testing with simple text'
|
||||
l = Line(len(t))
|
||||
set_text_in_line(l, t)
|
||||
self.ae(str(l), t)
|
||||
self.ae(str(l.copy()), t)
|
||||
l.continued = False
|
||||
l2 = l.copy()
|
||||
self.assertFalse(l2.continued)
|
||||
self.ae(l, l2)
|
||||
l2.char[1] = 23
|
||||
self.assertNotEqual(l, l2)
|
||||
Reference in New Issue
Block a user