From a467d2984ee1d562e97ea6f6f3846243a962e8ff Mon Sep 17 00:00:00 2001 From: Griatch Date: Thu, 13 Oct 2016 20:12:39 +0200 Subject: [PATCH] Make TestCommand unittest base handle non-text outputfuncs from msg() calls. This is done by primarily using text, and if that is None, by converting the entirety of the alternative kwargs to strings. Implements #1091." --- evennia/commands/default/tests.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/evennia/commands/default/tests.py b/evennia/commands/default/tests.py index 432d393f5b..fe778d9761 100644 --- a/evennia/commands/default/tests.py +++ b/evennia/commands/default/tests.py @@ -20,7 +20,7 @@ from mock import Mock from evennia.commands.default.cmdset_character import CharacterCmdSet from evennia.utils.test_resources import EvenniaTest from evennia.commands.default import help, general, system, admin, player, building, batchprocess, comms -from evennia.utils import ansi +from evennia.utils import ansi, utils from evennia.server.sessionhandler import SESSIONS @@ -67,8 +67,9 @@ class CommandTest(EvenniaTest): cmdobj.parse() cmdobj.func() cmdobj.at_post_cmd() - # clean out prettytable sugar - stored_msg = [args[0] if args else kwargs.get("text",kwargs) for name, args, kwargs in receiver.msg.mock_calls] + # clean out prettytable sugar. We only operate on text-type + stored_msg = [args[0] if args and args[0] else kwargs.get("text",utils.to_str(kwargs, force_string=True)) + for name, args, kwargs in receiver.msg.mock_calls] returned_msg = "||".join(_RE.sub("", mess) for mess in stored_msg) returned_msg = ansi.parse_ansi(returned_msg, strip_ansi=noansi).strip() if msg is not None: