Add simple ContentHandler unit test

This commit is contained in:
Griatch 2020-04-13 11:34:12 +02:00
parent 74b73c69f9
commit 556091c395
2 changed files with 15 additions and 1 deletions

View file

@ -1,6 +1,7 @@
from evennia.utils.test_resources import EvenniaTest from evennia.utils.test_resources import EvenniaTest
from evennia import DefaultObject, DefaultCharacter, DefaultRoom, DefaultExit from evennia import DefaultObject, DefaultCharacter, DefaultRoom, DefaultExit
from evennia.objects.models import ObjectDB from evennia.objects.models import ObjectDB
from evennia.utils import create
class DefaultObjectTest(EvenniaTest): class DefaultObjectTest(EvenniaTest):
@ -145,3 +146,16 @@ class TestObjectManager(EvenniaTest):
self.assertEqual(obj2.attributes.get(key="phrase"), "xyzzy") self.assertEqual(obj2.attributes.get(key="phrase"), "xyzzy")
self.assertEqual(self.obj1.attributes.get(key="phrase", category="adventure"), "plugh") self.assertEqual(self.obj1.attributes.get(key="phrase", category="adventure"), "plugh")
self.assertEqual(obj2.attributes.get(key="phrase", category="adventure"), "plugh") self.assertEqual(obj2.attributes.get(key="phrase", category="adventure"), "plugh")
class TestContentHandler(EvenniaTest):
"Test the ContentHandler (obj.contents)"
def test_cache_clearing(self):
self.assertTrue(self.obj1 in self.room1.contents)
self.assertTrue(self.obj2 in self.room1.contents)
obj3 = create.create_object(key="obj3", location=self.room1)
self.assertTrue(obj3 in self.room1.contents)
obj3.delete()
self.assertFalse(obj3 in self.room1.contents)

View file

@ -38,7 +38,7 @@ def unload_module(module):
an object, the module in which that object sits will be unloaded. A string an object, the module in which that object sits will be unloaded. A string
should directly give the module pathname to unload. should directly give the module pathname to unload.
Example: Example:
# (in a test method) # (in a test method)
unload_module(foo) unload_module(foo)
with mock.patch("foo.GLOBALTHING", "mockval"): with mock.patch("foo.GLOBALTHING", "mockval"):