summaryrefslogtreecommitdiff
path: root/urwid/tests/test_font.py
diff options
context:
space:
mode:
authorAlexey Stepanov <penguinolog@users.noreply.github.com>2023-05-09 09:13:40 +0200
committerGitHub <noreply@github.com>2023-05-09 09:13:40 +0200
commitffbfa07533809a523938d5e342ff7482a12dd5d0 (patch)
treef82251e47e72b9fe873f0eb20410c105387407b9 /urwid/tests/test_font.py
parentd26cb42a9fd28cb0743ad04d5ed2a0c7f28b89e3 (diff)
downloadurwid-master.tar.gz
Fix `TextCanvas` `CanvasError("Attribute extends beyond text...")` (#555)HEADmaster
* Fix TextCanvas `CanvasError("Attribute extends beyond text...") * `[[]] * ...` causes list of 1 list with pointers amount equal to multiplier instead of "list of lists" * Add 2 basic font tests which check for Canvas create issue * Add few type annotations during debug process Fix: #554 * Force tests to restore default encoding in tearDown Tests order change should not cause tests failures --------- Co-authored-by: Aleksei Stepanov <alekseis@nvidia.com>
Diffstat (limited to 'urwid/tests/test_font.py')
-rw-r--r--urwid/tests/test_font.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/urwid/tests/test_font.py b/urwid/tests/test_font.py
new file mode 100644
index 0000000..3c9be7a
--- /dev/null
+++ b/urwid/tests/test_font.py
@@ -0,0 +1,30 @@
+from __future__ import annotations
+
+import unittest
+
+import urwid
+
+
+class TestFontRender(unittest.TestCase):
+ def setUp(self) -> None:
+ self.old_encoding = urwid.util._target_encoding
+ urwid.set_encoding("utf-8")
+
+ def tearDown(self) -> None:
+ urwid.set_encoding(self.old_encoding)
+
+ def test_001_basic(self):
+ font = urwid.Thin3x3Font()
+ rendered = b'\n'.join(font.render("1").text).decode()
+ expected = ' ┐ \n │ \n ┴ '
+ self.assertEqual(expected, rendered)
+
+ def test_002_non_rect(self):
+ """Test non rect symbol, which causes spaces based padding.
+
+ Lines as bytes should be not equal length.
+ """
+ font = urwid.Thin3x3Font()
+ rendered = b'\n'.join(font.render("2").text).decode()
+ expected = '┌─┐\n┌─┘\n└─ '
+ self.assertEqual(expected, rendered)