Merge pull request #3599 from blongden/test_mixin_fix
Check msg from at_pre_cmd
This commit is contained in:
commit
7cd713d0c6
2 changed files with 44 additions and 34 deletions
|
|
@ -2263,3 +2263,16 @@ class TestSystemCommands(BaseEvenniaCommandTest):
|
||||||
multimatch.matches = matches
|
multimatch.matches = matches
|
||||||
|
|
||||||
self.call(multimatch, "look", "")
|
self.call(multimatch, "look", "")
|
||||||
|
|
||||||
|
class TestPreCmdOutputTestable(BaseEvenniaCommandTest):
|
||||||
|
def test_pre_cmd(self):
|
||||||
|
class CmdTest(Command):
|
||||||
|
def at_pre_cmd(self):
|
||||||
|
self.msg("This should be testable")
|
||||||
|
return True
|
||||||
|
|
||||||
|
def func(self):
|
||||||
|
self.msg("This should never be executed")
|
||||||
|
return
|
||||||
|
|
||||||
|
self.call(CmdTest(), "test", "This should be testable")
|
||||||
|
|
@ -433,7 +433,6 @@ class EvenniaCommandTestMixin:
|
||||||
cmdobj.raw_string = raw_string if raw_string is not None else cmdobj.key + " " + input_args
|
cmdobj.raw_string = raw_string if raw_string is not None else cmdobj.key + " " + input_args
|
||||||
cmdobj.obj = obj or (caller if caller else self.char1)
|
cmdobj.obj = obj or (caller if caller else self.char1)
|
||||||
inputs = inputs or []
|
inputs = inputs or []
|
||||||
|
|
||||||
# set up receivers
|
# set up receivers
|
||||||
receiver_mapping = {}
|
receiver_mapping = {}
|
||||||
if isinstance(msg, dict):
|
if isinstance(msg, dict):
|
||||||
|
|
@ -458,12 +457,10 @@ class EvenniaCommandTestMixin:
|
||||||
# cmdhandler. This will have the mocked .msg be called as part of the
|
# cmdhandler. This will have the mocked .msg be called as part of the
|
||||||
# execution. Mocks remembers what was sent to them so we will be able
|
# execution. Mocks remembers what was sent to them so we will be able
|
||||||
# to retrieve what was sent later.
|
# to retrieve what was sent later.
|
||||||
|
if not cmdobj.at_pre_cmd():
|
||||||
try:
|
try:
|
||||||
if cmdobj.at_pre_cmd():
|
|
||||||
return
|
|
||||||
cmdobj.parse()
|
cmdobj.parse()
|
||||||
ret = cmdobj.func()
|
ret = cmdobj.func()
|
||||||
|
|
||||||
# handle func's with yield in them (making them generators)
|
# handle func's with yield in them (making them generators)
|
||||||
if isinstance(ret, types.GeneratorType):
|
if isinstance(ret, types.GeneratorType):
|
||||||
while True:
|
while True:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue