This repository has been archived on 2024-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
Bebop/bebop/tests/test_rendering.py

42 lines
1.2 KiB
Python
Raw Normal View History

2021-02-12 19:01:42 +01:00
import unittest
from ..rendering import _explode_words, _find_next_sep, wrap_words
class TestRenderer(unittest.TestCase):
def test_wrap_words(self):
t = "wrap me wrap me youcantwrapthisonewithoutforce bla bla bla bla"
lines = wrap_words(t, 10)
expected = [
"wrap me ",
"wrap me ",
"youcantwr-",
"apthisone-",
"withoutfo-",
"rce bla ",
"bla bla ",
"bla",
]
self.assertListEqual(lines, expected)
def test_explode_words(self):
t = "unsplittableword word-dash tabatmyleft dot.sep"
words = _explode_words(t)
expected = [
"unsplittableword", " ", "word-", "dash", " ", "tabatmyleft",
" ", "dot.sep"
]
self.assertListEqual(words, expected)
def test_find_next_sep(self):
t = "unsplittableword word-dash"
sep, index = _find_next_sep(t)
self.assertEqual((sep, index), (" ", 16))
t = t[17:]
sep, index = _find_next_sep(t)
self.assertEqual((sep, index), ("-", 4))
t = t[5:]
sep, index = _find_next_sep(t)
self.assertEqual((sep, index), ("", 0))