diff options
author | Alexey Stepanov <penguinolog@users.noreply.github.com> | 2023-05-09 09:13:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-09 09:13:40 +0200 |
commit | ffbfa07533809a523938d5e342ff7482a12dd5d0 (patch) | |
tree | f82251e47e72b9fe873f0eb20410c105387407b9 /urwid/tests/test_util.py | |
parent | d26cb42a9fd28cb0743ad04d5ed2a0c7f28b89e3 (diff) | |
download | urwid-master.tar.gz |
* 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_util.py')
-rw-r--r-- | urwid/tests/test_util.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/urwid/tests/test_util.py b/urwid/tests/test_util.py index 06de8c8..d893eac 100644 --- a/urwid/tests/test_util.py +++ b/urwid/tests/test_util.py @@ -8,6 +8,12 @@ from urwid import util class CalcWidthTest(unittest.TestCase): + def setUp(self) -> None: + self.old_encoding = urwid.util._target_encoding + + def tearDown(self) -> None: + urwid.set_encoding(self.old_encoding) + def wtest(self, desc, s, exp): s = s.encode('iso8859-1') result = util.calc_width( s, 0, len(s)) @@ -29,6 +35,12 @@ class CalcWidthTest(unittest.TestCase): class ConvertDecSpecialTest(unittest.TestCase): + def setUp(self) -> None: + self.old_encoding = urwid.util._target_encoding + + def tearDown(self) -> None: + urwid.set_encoding(self.old_encoding) + def ctest(self, desc, s, exp, expcs): exp = exp.encode('iso8859-1') util.set_encoding('ascii') @@ -51,8 +63,12 @@ class ConvertDecSpecialTest(unittest.TestCase): class WithinDoubleByteTest(unittest.TestCase): def setUp(self): + self.old_encoding = urwid.util._target_encoding urwid.set_encoding("euc-jp") + def tearDown(self) -> None: + urwid.set_encoding(self.old_encoding) + def wtest(self, s, ls, pos, expected, desc): result = util.within_double_byte(s.encode('iso8859-1'), ls, pos) assert result==expected, f"{desc} got:{result!r} expected: {expected!r}" @@ -88,6 +104,12 @@ class WithinDoubleByteTest(unittest.TestCase): class CalcTextPosTest(unittest.TestCase): + def setUp(self) -> None: + self.old_encoding = urwid.util._target_encoding + + def tearDown(self) -> None: + urwid.set_encoding(self.old_encoding) + def ctptest(self, text, tests): text = text.encode('iso8859-1') for s,e,p, expected in tests: |