Call parse_ansi on each returned message before passing to regex to handle individually colored characters.
This commit is contained in:
parent
cb0c2d11f2
commit
80c6d401e5
2 changed files with 8 additions and 5 deletions
|
|
@ -94,8 +94,11 @@ class CommandTest(EvenniaTest):
|
||||||
# Get the first element of a tuple if msg received a tuple instead of a string
|
# Get the first element of a tuple if msg received a tuple instead of a string
|
||||||
stored_msg = [smsg[0] if isinstance(smsg, tuple) else smsg for smsg in stored_msg]
|
stored_msg = [smsg[0] if isinstance(smsg, tuple) else smsg for smsg in stored_msg]
|
||||||
if msg is not None:
|
if msg is not None:
|
||||||
returned_msg = "||".join(_RE.sub("", mess) for mess in stored_msg)
|
# set our separator for returned messages based on parsing ansi or not
|
||||||
returned_msg = ansi.parse_ansi(returned_msg, strip_ansi=noansi).strip()
|
msg_sep = "|" if noansi else "||"
|
||||||
|
# Have to strip ansi for each returned message for the regex to handle it correctly
|
||||||
|
returned_msg = msg_sep.join(_RE.sub("", ansi.parse_ansi(mess, strip_ansi=noansi))
|
||||||
|
for mess in stored_msg).strip()
|
||||||
if msg == "" and returned_msg or not returned_msg.startswith(msg.strip()):
|
if msg == "" and returned_msg or not returned_msg.startswith(msg.strip()):
|
||||||
sep1 = "\n" + "=" * 30 + "Wanted message" + "=" * 34 + "\n"
|
sep1 = "\n" + "=" * 30 + "Wanted message" + "=" * 34 + "\n"
|
||||||
sep2 = "\n" + "=" * 30 + "Returned message" + "=" * 32 + "\n"
|
sep2 = "\n" + "=" * 30 + "Returned message" + "=" * 32 + "\n"
|
||||||
|
|
@ -166,7 +169,7 @@ class TestSystem(CommandTest):
|
||||||
self.call(system.CmdPy(), "1+2", ">>> 1+2|3")
|
self.call(system.CmdPy(), "1+2", ">>> 1+2|3")
|
||||||
|
|
||||||
def test_scripts(self):
|
def test_scripts(self):
|
||||||
self.call(system.CmdScripts(), "", "| dbref |")
|
self.call(system.CmdScripts(), "", "dbref ")
|
||||||
|
|
||||||
def test_objects(self):
|
def test_objects(self):
|
||||||
self.call(system.CmdObjects(), "", "Object subtype totals")
|
self.call(system.CmdObjects(), "", "Object subtype totals")
|
||||||
|
|
|
||||||
|
|
@ -688,8 +688,8 @@ class TestMail(CommandTest):
|
||||||
"You have received a new @mail from TestAccount2(account 2)|You sent your message.", caller=self.account2)
|
"You have received a new @mail from TestAccount2(account 2)|You sent your message.", caller=self.account2)
|
||||||
self.call(mail.CmdMail(), "TestAccount=Message 1", "You sent your message.", caller=self.account2)
|
self.call(mail.CmdMail(), "TestAccount=Message 1", "You sent your message.", caller=self.account2)
|
||||||
self.call(mail.CmdMail(), "TestAccount=Message 2", "You sent your message.", caller=self.account2)
|
self.call(mail.CmdMail(), "TestAccount=Message 2", "You sent your message.", caller=self.account2)
|
||||||
self.call(mail.CmdMail(), "", "------------------------------------------------------------------------------| ID: From: Subject:", caller=self.account)
|
self.call(mail.CmdMail(), "", "| ID: From: Subject:", caller=self.account)
|
||||||
self.call(mail.CmdMail(), "2", "------------------------------------------------------------------------------\nFrom: TestAccount2", caller=self.account)
|
self.call(mail.CmdMail(), "2", "From: TestAccount2", caller=self.account)
|
||||||
self.call(mail.CmdMail(), "/forward TestAccount2 = 1/Forward message", "You sent your message.|Message forwarded.", caller=self.account)
|
self.call(mail.CmdMail(), "/forward TestAccount2 = 1/Forward message", "You sent your message.|Message forwarded.", caller=self.account)
|
||||||
self.call(mail.CmdMail(), "/reply 2=Reply Message2", "You sent your message.", caller=self.account)
|
self.call(mail.CmdMail(), "/reply 2=Reply Message2", "You sent your message.", caller=self.account)
|
||||||
self.call(mail.CmdMail(), "/delete 2", "Message 2 deleted", caller=self.account)
|
self.call(mail.CmdMail(), "/delete 2", "Message 2 deleted", caller=self.account)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue