evennia.utils.test_resources¶
Various helper resources for writing unittests.
-
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'
Notes
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.TestCaseBase test for Evennia, sets up a basic environment.
-
account_typeclass¶
-
object_typeclass¶
-
character_typeclass¶
-
exit_typeclass¶ alias of
evennia.objects.objects.DefaultExit
-
room_typeclass¶ alias of
evennia.objects.objects.DefaultRoom
-
script_typeclass¶
-
-
class
evennia.utils.test_resources.LocalEvenniaTest(methodName='runTest')[source]¶ Bases:
evennia.utils.test_resources.EvenniaTestThis 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'¶
-