summaryrefslogtreecommitdiff
path: root/urwid/tests/test_graphics.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_graphics.py
parentd26cb42a9fd28cb0743ad04d5ed2a0c7f28b89e3 (diff)
downloadurwid-ffbfa07533809a523938d5e342ff7482a12dd5d0.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_graphics.py')
-rw-r--r--urwid/tests/test_graphics.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/urwid/tests/test_graphics.py b/urwid/tests/test_graphics.py
index f731208..1ae1f98 100644
--- a/urwid/tests/test_graphics.py
+++ b/urwid/tests/test_graphics.py
@@ -7,6 +7,13 @@ from urwid import graphics
class LineBoxTest(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 border(self, tl, t, tr, l, r, bl, b, br):
return [b''.join([tl, t, tr]),
b''.join([l, b" ", r]),
@@ -14,7 +21,6 @@ class LineBoxTest(unittest.TestCase):
def test_linebox_pack(self):
# Bug #346 'pack' Padding does not run with LineBox
- urwid.set_encoding("utf-8")
t = urwid.Text("AAA\nCCC\nDDD")
size = t.pack()
l = urwid.LineBox(t)
@@ -23,7 +29,6 @@ class LineBoxTest(unittest.TestCase):
self.assertEqual(l.pack()[1], size[1] + 2)
def test_linebox_border(self):
- urwid.set_encoding("utf-8")
t = urwid.Text("")
l = urwid.LineBox(t).render((3,)).text
@@ -87,8 +92,14 @@ class BarGraphTest(unittest.TestCase):
(1,[(3,3)]) ] )
class SmoothBarGraphTest(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 sbgtest(self, desc, data, top, exp ):
- urwid.set_encoding('utf-8')
g = urwid.BarGraph( ['black','red','blue'],
None, {(1,0):'red/black', (2,1):'blue/red'})
g.set_data( data, top )