mirror of
https://github.com/evennia/evennia.git
synced 2026-04-05 23:47:16 +02:00
Fixed issues with transformation functions on ANSIString.
This commit is contained in:
parent
7fd47eb386
commit
834b039a0d
2 changed files with 12 additions and 1 deletions
|
|
@ -405,11 +405,13 @@ def _transform(func_name):
|
|||
def wrapped(self, *args, **kwargs):
|
||||
replacement_string = _query_super(func_name)(self, *args, **kwargs)
|
||||
to_string = []
|
||||
char_counter = 0
|
||||
for index in range(0, len(self._raw_string)):
|
||||
if index in self._code_indexes:
|
||||
to_string.append(self._raw_string[index])
|
||||
elif index in self._char_indexes:
|
||||
to_string.append(replacement_string[index])
|
||||
to_string.append(replacement_string[char_counter])
|
||||
char_counter += 1
|
||||
return ANSIString(''.join(to_string), decoded=True)
|
||||
return wrapped
|
||||
|
||||
|
|
|
|||
|
|
@ -110,3 +110,12 @@ class ANSIStringTestCase(TestCase):
|
|||
ANSI codes.
|
||||
"""
|
||||
self.assertEqual(len(ANSIString('{gTest{n')), 4)
|
||||
|
||||
def test_capitalize(self):
|
||||
"""
|
||||
Make sure that capitalization works. This is the simplest of the
|
||||
_transform functions.
|
||||
"""
|
||||
target = ANSIString('{gtest{n')
|
||||
result = u'\x1b[1m\x1b[32mTest\x1b[0m'
|
||||
self.checker(target.capitalize(), result, u'Test')
|
||||
Loading…
Add table
Add a link
Reference in a new issue