Merge branch 'master' into develop

This commit is contained in:
Griatch 2018-01-02 21:52:43 +01:00
commit 5d1c3cb27e
7 changed files with 43 additions and 20 deletions

View file

@ -824,9 +824,30 @@ class TestTutorialWorldMob(EvenniaTest):
from evennia.contrib.tutorial_world import objects as tutobjects
from mock.mock import MagicMock
from twisted.trial.unittest import TestCase as TwistedTestCase
from twisted.internet.base import DelayedCall
DelayedCall.debug = True
class TestTutorialWorldObjects(CommandTest):
def _mockdelay(tim, func, *args, **kwargs):
func(*args, **kwargs)
return MagicMock()
def _mockdeferLater(reactor, timedelay, callback, *args, **kwargs):
callback(*args, **kwargs)
return MagicMock()
class TestTutorialWorldObjects(TwistedTestCase, CommandTest):
def setUp(self):
self.patch(sys.modules['evennia.contrib.tutorial_world.objects'], 'delay', _mockdelay)
self.patch(sys.modules['evennia.scripts.taskhandler'], 'deferLater', _mockdeferLater)
super(TestTutorialWorldObjects, self).setUp()
def test_tutorialobj(self):
obj1 = create_object(tutobjects.TutorialObject, key="tutobj")
obj1.reset()
@ -848,10 +869,7 @@ class TestTutorialWorldObjects(CommandTest):
def test_lightsource(self):
light = create_object(tutobjects.LightSource, key="torch", location=self.room1)
self.call(tutobjects.CmdLight(), "", "You light torch.", obj=light)
light._burnout()
if hasattr(light, "deferred"):
light.deferred.cancel()
self.call(tutobjects.CmdLight(), "", "A torch on the floor flickers and dies.|You light torch.", obj=light)
self.assertFalse(light.pk)
def test_crumblingwall(self):
@ -869,12 +887,12 @@ class TestTutorialWorldObjects(CommandTest):
"You shift the weedy green root upwards.|Holding aside the root you think you notice something behind it ...", obj=wall)
self.call(tutobjects.CmdPressButton(), "",
"You move your fingers over the suspicious depression, then gives it a decisive push. First", obj=wall)
self.assertTrue(wall.db.button_exposed)
self.assertTrue(wall.db.exit_open)
# we patch out the delay, so these are closed immediately
self.assertFalse(wall.db.button_exposed)
self.assertFalse(wall.db.exit_open)
wall.reset()
if hasattr(wall, "deferred"):
wall.deferred.cancel()
wall.delete()
return wall.deferred
def test_weapon(self):
weapon = create_object(tutobjects.Weapon, key="sword", location=self.char1)

View file

@ -23,8 +23,7 @@ from future.utils import listvalues
import random
from evennia import DefaultObject, DefaultExit, Command, CmdSet
from evennia import utils
from evennia.utils import search
from evennia.utils import search, delay
from evennia.utils.spawner import spawn
# -------------------------------------------------------------
@ -373,7 +372,7 @@ class LightSource(TutorialObject):
# start the burn timer. When it runs out, self._burnout
# will be called. We store the deferred so it can be
# killed in unittesting.
self.deferred = utils.delay(60 * 3, self._burnout)
self.deferred = delay(60 * 3, self._burnout)
return True
@ -645,7 +644,7 @@ class CrumblingWall(TutorialObject, DefaultExit):
self.db.exit_open = True
# start a 45 second timer before closing again. We store the deferred so it can be
# killed in unittesting.
self.deferred = utils.delay(45, self.reset)
self.deferred = delay(45, self.reset)
def _translate_position(self, root, ipos):
"""Translates the position into words"""