summaryrefslogtreecommitdiff
path: root/urwid/tests/test_font.py
blob: 3c9be7a93487870a468fbc04fbeec84d7c50909f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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)