evennia.utils.test_resources

Various helper resources for writing unittests.

evennia.utils.test_resources.mockdelay(timedelay, callback, *args, **kwargs)[source]
evennia.utils.test_resources.mockdeferLater(reactor, timedelay, callback, *args, **kwargs)[source]
evennia.utils.test_resources.unload_module(module)[source]

Reset import so one can mock global constants.

Parameters

module (module, object or str) – The module will be removed so it will have to be imported again. If given an object, the module in which that object sits will be unloaded. A string should directly give the module pathname to unload.

Example

# (in a test method)
unload_module(foo)
with mock.patch("foo.GLOBALTHING", "mockval"):
    import foo
    ... # test code using foo.GLOBALTHING, now set to 'mockval'

This allows for mocking constants global to the module, since otherwise those would not be mocked (since a module is only loaded once).

class evennia.utils.test_resources.EvenniaTest(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

Base test for Evennia, sets up a basic environment.

account_typeclass

alias of evennia.accounts.accounts.DefaultAccount

object_typeclass

alias of evennia.objects.objects.DefaultObject

character_typeclass

alias of evennia.objects.objects.DefaultCharacter

exit_typeclass

alias of evennia.objects.objects.DefaultExit

room_typeclass

alias of evennia.objects.objects.DefaultRoom

script_typeclass

alias of evennia.scripts.scripts.DefaultScript

setUp()[source]

Sets up testing environment

tearDown()[source]

Hook method for deconstructing the test fixture after testing it.

class evennia.utils.test_resources.LocalEvenniaTest(methodName='runTest')[source]

Bases: evennia.utils.test_resources.EvenniaTest

This test class is intended for inheriting in mygame tests. It helps ensure your tests are run with your own objects.

account_typeclass = 'typeclasses.accounts.Account'
object_typeclass = 'typeclasses.objects.Object'
character_typeclass = 'typeclasses.characters.Character'
exit_typeclass = 'typeclasses.exits.Exit'
room_typeclass = 'typeclasses.rooms.Room'
script_typeclass = 'typeclasses.scripts.Script'