mirror of
https://github.com/evennia/evennia.git
synced 2026-04-04 06:57:16 +02:00
Exploring strange ansi string error
This commit is contained in:
parent
63f33e70f1
commit
9c5d345763
2 changed files with 49 additions and 53 deletions
|
|
@ -12,11 +12,6 @@ has markers in it to denounce fields to fill. The markers map the
|
|||
absolute size of the field and will be filled with an `evtable.EvCell`
|
||||
object when displaying the form.
|
||||
|
||||
Note, when printing examples with ANSI color, you need to wrap
|
||||
the output in `unicode()`, such as `print unicode(form)`. This is
|
||||
due to a bug in the Python parser and the `print` statement.
|
||||
|
||||
|
||||
Example of input file `testform.py`:
|
||||
|
||||
```python
|
||||
|
|
@ -439,10 +434,6 @@ class EvForm(object):
|
|||
"Prints the form"
|
||||
return str(ANSIString("\n").join([line for line in self.form]))
|
||||
|
||||
def __unicode__(self):
|
||||
"prints the form"
|
||||
return str(ANSIString("\n").join([line for line in self.form]))
|
||||
|
||||
|
||||
def _test():
|
||||
"test evform. This is used by the unittest system."
|
||||
|
|
@ -470,5 +461,4 @@ def _test():
|
|||
# add the tables to the proper ids in the form
|
||||
form.map(tables={"A": tableA,
|
||||
"B": tableB})
|
||||
# unicode is required since the example contains non-ascii characters
|
||||
return str(form)
|
||||
|
|
|
|||
|
|
@ -9,49 +9,55 @@ from evennia.utils import evform
|
|||
class TestEvForm(TestCase):
|
||||
def test_form(self):
|
||||
self.maxDiff = None
|
||||
form = evform._test()
|
||||
self.assertEqual(form,
|
||||
'.------------------------------------------------.\n'
|
||||
'| |\n'
|
||||
'| Name: \x1b[0m\x1b[1m\x1b[32mTom\x1b[1m\x1b[32m \x1b'
|
||||
'[1m\x1b[32mthe\x1b[1m\x1b[32m \x1b[0m \x1b[0m '
|
||||
'Account: \x1b[0m\x1b[1m\x1b[33mGriatch '
|
||||
'\x1b[0m\x1b[0m\x1b[1m\x1b[32m\x1b[1m\x1b[32m\x1b[1m\x1b[32m\x1b[1m\x1b[32m\x1b[0m\x1b[0m '
|
||||
'|\n'
|
||||
'| \x1b[0m\x1b[1m\x1b[32mBouncer\x1b[0m \x1b[0m |\n'
|
||||
'| |\n'
|
||||
' >----------------------------------------------< \n'
|
||||
'| |\n'
|
||||
'| Desc: \x1b[0mA sturdy \x1b[0m \x1b[0m'
|
||||
' STR: \x1b[0m12 \x1b[0m\x1b[0m\x1b[0m\x1b[0m'
|
||||
' DEX: \x1b[0m10 \x1b[0m\x1b[0m\x1b[0m\x1b[0m |\n'
|
||||
'| \x1b[0mfellow\x1b[0m \x1b[0m'
|
||||
' INT: \x1b[0m5 \x1b[0m\x1b[0m\x1b[0m\x1b[0m'
|
||||
' STA: \x1b[0m18 \x1b[0m\x1b[0m\x1b[0m\x1b[0m |\n'
|
||||
'| \x1b[0m \x1b[0m'
|
||||
' LUC: \x1b[0m10 \x1b[0m\x1b[0m\x1b[0m'
|
||||
' MAG: \x1b[0m3 \x1b[0m\x1b[0m\x1b[0m |\n'
|
||||
'| |\n'
|
||||
' >----------.-----------------------------------< \n'
|
||||
'| | |\n'
|
||||
'| \x1b[0mHP\x1b[0m|\x1b[0mMV \x1b[0m|\x1b[0mMP\x1b[0m '
|
||||
'| \x1b[0mSkill \x1b[0m|\x1b[0mValue \x1b[0m'
|
||||
'|\x1b[0mExp \x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m |\n'
|
||||
'| ~~+~~~+~~ | ~~~~~~~~~~~+~~~~~~~~~~+~~~~~~~~~~~ |\n'
|
||||
'| \x1b[0m**\x1b[0m|\x1b[0m***\x1b[0m\x1b[0m|\x1b[0m**\x1b[0m\x1b[0m '
|
||||
'| \x1b[0mShooting \x1b[0m|\x1b[0m12 \x1b[0m'
|
||||
'|\x1b[0m550/1200 \x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m |\n'
|
||||
'| \x1b[0m \x1b[0m|\x1b[0m**\x1b[0m \x1b[0m|\x1b[0m*\x1b[0m \x1b[0m '
|
||||
'| \x1b[0mHerbalism \x1b[0m|\x1b[0m14 \x1b[0m'
|
||||
'|\x1b[0m990/1400 \x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m |\n'
|
||||
'| \x1b[0m \x1b[0m|\x1b[0m \x1b[0m|\x1b[0m \x1b[0m '
|
||||
'| \x1b[0mSmithing \x1b[0m|\x1b[0m9 \x1b[0m'
|
||||
'|\x1b[0m205/900 \x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m |\n'
|
||||
'| | |\n'
|
||||
' -----------`-------------------------------------\n'
|
||||
' Footer: \x1b[0mrev 1 \x1b[0m \n'
|
||||
' info \n'
|
||||
' ')
|
||||
form1 = evform._test()
|
||||
print("len(form1): {}".format(len(form1)))
|
||||
form2 = evform._test()
|
||||
print("len(form2): {}".format(len(form2)))
|
||||
|
||||
self.assertEqual(form1, form2)
|
||||
|
||||
# self.assertEqual(form, "")
|
||||
# '.------------------------------------------------.\n'
|
||||
# '| |\n'
|
||||
# '| Name: \x1b[0m\x1b[1m\x1b[32mTom\x1b[1m\x1b[32m \x1b'
|
||||
# '[1m\x1b[32mthe\x1b[1m\x1b[32m \x1b[0m \x1b[0m '
|
||||
# 'Account: \x1b[0m\x1b[1m\x1b[33mGriatch '
|
||||
# '\x1b[0m\x1b[0m\x1b[1m\x1b[32m\x1b[1m\x1b[32m\x1b[1m\x1b[32m\x1b[1m\x1b[32m\x1b[0m\x1b[0m '
|
||||
# '|\n'
|
||||
# '| \x1b[0m\x1b[1m\x1b[32mBouncer\x1b[0m \x1b[0m |\n'
|
||||
# '| |\n'
|
||||
# ' >----------------------------------------------< \n'
|
||||
# '| |\n'
|
||||
# '| Desc: \x1b[0mA sturdy \x1b[0m \x1b[0m'
|
||||
# ' STR: \x1b[0m12 \x1b[0m\x1b[0m\x1b[0m\x1b[0m'
|
||||
# ' DEX: \x1b[0m10 \x1b[0m\x1b[0m\x1b[0m\x1b[0m |\n'
|
||||
# '| \x1b[0mfellow\x1b[0m \x1b[0m'
|
||||
# ' INT: \x1b[0m5 \x1b[0m\x1b[0m\x1b[0m\x1b[0m'
|
||||
# ' STA: \x1b[0m18 \x1b[0m\x1b[0m\x1b[0m\x1b[0m |\n'
|
||||
# '| \x1b[0m \x1b[0m'
|
||||
# ' LUC: \x1b[0m10 \x1b[0m\x1b[0m\x1b[0m'
|
||||
# ' MAG: \x1b[0m3 \x1b[0m\x1b[0m\x1b[0m |\n'
|
||||
# '| |\n'
|
||||
# ' >----------.-----------------------------------< \n'
|
||||
# '| | |\n'
|
||||
# '| \x1b[0mHP\x1b[0m|\x1b[0mMV \x1b[0m|\x1b[0mMP\x1b[0m '
|
||||
# '| \x1b[0mSkill \x1b[0m|\x1b[0mValue \x1b[0m'
|
||||
# '|\x1b[0mExp \x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m |\n'
|
||||
# '| ~~+~~~+~~ | ~~~~~~~~~~~+~~~~~~~~~~+~~~~~~~~~~~ |\n'
|
||||
# '| \x1b[0m**\x1b[0m|\x1b[0m***\x1b[0m\x1b[0m|\x1b[0m**\x1b[0m\x1b[0m '
|
||||
# '| \x1b[0mShooting \x1b[0m|\x1b[0m12 \x1b[0m'
|
||||
# '|\x1b[0m550/1200 \x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m |\n'
|
||||
# '| \x1b[0m \x1b[0m|\x1b[0m**\x1b[0m \x1b[0m|\x1b[0m*\x1b[0m \x1b[0m '
|
||||
# '| \x1b[0mHerbalism \x1b[0m|\x1b[0m14 \x1b[0m'
|
||||
# '|\x1b[0m990/1400 \x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m |\n'
|
||||
# '| \x1b[0m \x1b[0m|\x1b[0m \x1b[0m|\x1b[0m \x1b[0m '
|
||||
# '| \x1b[0mSmithing \x1b[0m|\x1b[0m9 \x1b[0m'
|
||||
# '|\x1b[0m205/900 \x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m\x1b[0m |\n'
|
||||
# '| | |\n'
|
||||
# ' -----------`-------------------------------------\n'
|
||||
# ' Footer: \x1b[0mrev 1 \x1b[0m \n'
|
||||
# ' info \n'
|
||||
# ' ')
|
||||
|
||||
def test_ansi_escape(self):
|
||||
# note that in a msg() call, the result would be the correct |-----,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue