mirror of
https://github.com/evennia/evennia.git
synced 2026-04-01 13:37:17 +02:00
Isolate EvenniaTestCase/EvenniaCommandTest for pristine settings
This commit is contained in:
parent
f79d88e6cd
commit
d942c9cd08
40 changed files with 223 additions and 123 deletions
|
|
@ -23,7 +23,7 @@ from unittest.mock import patch, Mock, MagicMock
|
|||
|
||||
from evennia import DefaultRoom, DefaultExit, ObjectDB
|
||||
from evennia.commands.default.cmdset_character import CharacterCmdSet
|
||||
from evennia.utils.test_resources import EvenniaTest
|
||||
from evennia.utils.test_resources import EvenniaTest, LocalEvenniaTest
|
||||
from evennia.commands.default import (
|
||||
help as help_module,
|
||||
general,
|
||||
|
|
@ -57,8 +57,11 @@ _RE_STRIP_EVMENU = re.compile(r"^\+|-+\+|\+-+|--+|\|(?:\s|$)", re.MULTILINE)
|
|||
# ------------------------------------------------------------
|
||||
|
||||
@patch("evennia.server.portal.portal.LoopingCall", new=MagicMock())
|
||||
class CommandTest(EvenniaTest):
|
||||
class CommandTestMixin:
|
||||
"""
|
||||
Mixin to add to a test in order to provide the `.call` helper for
|
||||
testing the execution and returns of a command.
|
||||
|
||||
Tests a Command by running it and comparing what messages it sends with
|
||||
expected values. This tests without actually spinning up the cmdhandler
|
||||
for every test, which is more controlled.
|
||||
|
|
@ -68,7 +71,7 @@ class CommandTest(EvenniaTest):
|
|||
|
||||
from commands.echo import CmdEcho
|
||||
|
||||
class MyCommandTest(CommandTest):
|
||||
class MyCommandTest(EvenniaTest, CommandTestMixin):
|
||||
|
||||
def test_echo(self):
|
||||
'''
|
||||
|
|
@ -306,12 +309,26 @@ class CommandTest(EvenniaTest):
|
|||
return returned_msgs
|
||||
|
||||
|
||||
class EvenniaCommandTest(EvenniaTest, CommandTestMixin):
|
||||
"""
|
||||
Commands only using the default settings.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
class LocalEvenniaCommandTest(LocalEvenniaTest, CommandTestMixin):
|
||||
"""
|
||||
Parent class to inherit from - makes tests use your own
|
||||
classes and settings in mygame.
|
||||
|
||||
"""
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# Individual module Tests
|
||||
# ------------------------------------------------------------
|
||||
|
||||
|
||||
class TestGeneral(CommandTest):
|
||||
class TestGeneral(EvenniaCommandTest):
|
||||
def test_look(self):
|
||||
rid = self.room1.id
|
||||
self.call(general.CmdLook(), "here", "Room(#{})\nroom_desc".format(rid))
|
||||
|
|
@ -407,7 +424,7 @@ class TestGeneral(CommandTest):
|
|||
self.call(general.CmdAccess(), "", "Permission Hierarchy (climbing):")
|
||||
|
||||
|
||||
class TestHelp(CommandTest):
|
||||
class TestHelp(EvenniaCommandTest):
|
||||
|
||||
maxDiff = None
|
||||
|
||||
|
|
@ -557,7 +574,7 @@ class TestHelp(CommandTest):
|
|||
cmdset=TestCmdSet())
|
||||
|
||||
|
||||
class TestSystem(CommandTest):
|
||||
class TestSystem(EvenniaCommandTest):
|
||||
def test_py(self):
|
||||
# we are not testing CmdReload, CmdReset and CmdShutdown, CmdService or CmdTime
|
||||
# since the server is not running during these tests.
|
||||
|
|
@ -581,7 +598,7 @@ _TASK_HANDLER = None
|
|||
def func_test_cmd_tasks():
|
||||
return 'success'
|
||||
|
||||
class TestCmdTasks(CommandTest):
|
||||
class TestCmdTasks(EvenniaCommandTest):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
|
@ -741,7 +758,7 @@ class TestCmdTasks(CommandTest):
|
|||
self.call(system.CmdTasks(), f'/cancel', wanted_msg)
|
||||
|
||||
|
||||
class TestAdmin(CommandTest):
|
||||
class TestAdmin(EvenniaCommandTest):
|
||||
def test_emit(self):
|
||||
self.call(admin.CmdEmit(), "Char2 = Test", "Emitted to Char2:\nTest")
|
||||
|
||||
|
|
@ -772,7 +789,7 @@ class TestAdmin(CommandTest):
|
|||
)
|
||||
|
||||
|
||||
class TestAccount(CommandTest):
|
||||
class TestAccount(EvenniaCommandTest):
|
||||
def test_ooc_look(self):
|
||||
if settings.MULTISESSION_MODE < 2:
|
||||
self.call(
|
||||
|
|
@ -896,7 +913,7 @@ class TestAccount(CommandTest):
|
|||
)
|
||||
|
||||
|
||||
class TestBuilding(CommandTest):
|
||||
class TestBuilding(EvenniaCommandTest):
|
||||
def test_create(self):
|
||||
name = settings.BASE_OBJECT_TYPECLASS.rsplit(".", 1)[1]
|
||||
self.call(
|
||||
|
|
@ -1943,13 +1960,13 @@ class TestBuilding(CommandTest):
|
|||
import evennia.commands.default.comms as cmd_comms # noqa
|
||||
from evennia.utils.create import create_channel # noqa
|
||||
|
||||
class TestCommsChannel(CommandTest):
|
||||
class TestCommsChannel(EvenniaCommandTest):
|
||||
"""
|
||||
Test the central `channel` command.
|
||||
|
||||
"""
|
||||
def setUp(self):
|
||||
super(CommandTest, self).setUp()
|
||||
super(EvenniaCommandTest, self).setUp()
|
||||
self.channel = create_channel(
|
||||
key="testchannel",
|
||||
desc="A test channel")
|
||||
|
|
@ -2165,7 +2182,7 @@ class TestCommsChannel(CommandTest):
|
|||
from evennia.commands.default import comms # noqa
|
||||
|
||||
|
||||
class TestComms(CommandTest):
|
||||
class TestComms(EvenniaCommandTest):
|
||||
|
||||
def test_page(self):
|
||||
self.call(
|
||||
|
|
@ -2177,7 +2194,7 @@ class TestComms(CommandTest):
|
|||
)
|
||||
|
||||
|
||||
class TestBatchProcess(CommandTest):
|
||||
class TestBatchProcess(EvenniaCommandTest):
|
||||
"""
|
||||
Test the batch processor.
|
||||
|
||||
|
|
@ -2213,13 +2230,13 @@ class CmdInterrupt(Command):
|
|||
self.msg("in func")
|
||||
|
||||
|
||||
class TestInterruptCommand(CommandTest):
|
||||
class TestInterruptCommand(EvenniaCommandTest):
|
||||
def test_interrupt_command(self):
|
||||
ret = self.call(CmdInterrupt(), "")
|
||||
self.assertEqual(ret, "")
|
||||
|
||||
|
||||
class TestUnconnectedCommand(CommandTest):
|
||||
class TestUnconnectedCommand(EvenniaCommandTest):
|
||||
def test_info_command(self):
|
||||
# instead of using SERVER_START_TIME (0), we use 86400 because Windows won't let us use anything lower
|
||||
gametime.SERVER_START_TIME = 86400
|
||||
|
|
@ -2239,7 +2256,7 @@ class TestUnconnectedCommand(CommandTest):
|
|||
# Test syscommands
|
||||
|
||||
|
||||
class TestSystemCommands(CommandTest):
|
||||
class TestSystemCommands(EvenniaCommandTest):
|
||||
def test_simple_defaults(self):
|
||||
self.call(syscommands.SystemNoInput(), "")
|
||||
self.call(syscommands.SystemNoMatch(), "Huh?")
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ Building menu tests.
|
|||
|
||||
"""
|
||||
|
||||
from evennia.commands.default.tests import CommandTest
|
||||
from evennia.commands.default.tests import EvenniaCommandTest
|
||||
from . building_menu import BuildingMenu, CmdNoMatch
|
||||
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ class Submenu(BuildingMenu):
|
|||
self.add_choice("title", key="t", attr="key")
|
||||
|
||||
|
||||
class TestBuildingMenu(CommandTest):
|
||||
class TestBuildingMenu(EvenniaCommandTest):
|
||||
def setUp(self):
|
||||
super(TestBuildingMenu, self).setUp()
|
||||
self.menu = BuildingMenu(caller=self.char1, obj=self.room1, title="test")
|
||||
|
|
|
|||
|
|
@ -3,4 +3,10 @@ Custom gametime contrib - Griatch, vlgeoff 2017
|
|||
|
||||
"""
|
||||
|
||||
from .custom_gametime import * # noqa
|
||||
from .custom_gametime import time_to_tuple, UNITS # noqa
|
||||
from .custom_gametime import gametime_to_realtime # noqa
|
||||
from .custom_gametime import realtime_to_gametime # noqa
|
||||
from .custom_gametime import custom_gametime # noqa
|
||||
from .custom_gametime import real_seconds_until # noqa
|
||||
from .custom_gametime import schedule # noqa
|
||||
from .custom_gametime import GametimeScript # noqa
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ Testing custom game time
|
|||
# Testing custom_gametime
|
||||
from mock import Mock, patch
|
||||
from evennia.utils.test_resources import EvenniaTest
|
||||
from . import custom_gametime
|
||||
from .. import custom_gametime
|
||||
|
||||
|
||||
def _testcallback():
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@ Test email login.
|
|||
|
||||
"""
|
||||
|
||||
from evennia.commands.default.tests import CommandTest
|
||||
from evennia.commands.default.tests import EvenniaCommandTest
|
||||
from . import email_login
|
||||
|
||||
|
||||
class TestEmailLogin(CommandTest):
|
||||
class TestEmailLogin(EvenniaCommandTest):
|
||||
def test_connect(self):
|
||||
self.call(
|
||||
email_login.CmdUnconnectedConnect(),
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from textwrap import dedent
|
|||
|
||||
from django.conf import settings
|
||||
from evennia import ScriptDB
|
||||
from evennia.commands.default.tests import CommandTest
|
||||
from evennia.commands.default.tests import EvenniaCommandTest
|
||||
from evennia.objects.objects import ExitCommand
|
||||
from evennia.utils import ansi, utils
|
||||
from evennia.utils.create import create_object, create_script
|
||||
|
|
@ -246,7 +246,7 @@ class TestEventHandler(EvenniaTest):
|
|||
self.assertEqual(self.room1.callbacks.all(), {})
|
||||
|
||||
|
||||
class TestCmdCallback(CommandTest):
|
||||
class TestCmdCallback(EvenniaCommandTest):
|
||||
|
||||
"""Test the @callback command."""
|
||||
|
||||
|
|
@ -425,7 +425,7 @@ class TestCmdCallback(CommandTest):
|
|||
self.assertEqual(callback.valid, True)
|
||||
|
||||
|
||||
class TestDefaultCallbacks(CommandTest):
|
||||
class TestDefaultCallbacks(EvenniaCommandTest):
|
||||
|
||||
"""Test the default callbacks."""
|
||||
|
||||
|
|
|
|||
|
|
@ -4,4 +4,4 @@ Menu-login - Vinvent-lg 2016, Griatch 2019
|
|||
"""
|
||||
|
||||
from .menu_login import UnloggedinCmdSet # noqa
|
||||
from .menu_login import connection_screens # noqa
|
||||
from . import connection_screens # noqa
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ Test menu_login
|
|||
|
||||
"""
|
||||
|
||||
from evennia.commands.default.tests import CommandTest
|
||||
from evennia.commands.default.tests import EvenniaCommandTest
|
||||
from . import menu_login
|
||||
|
||||
|
||||
class TestMenuLogin(CommandTest):
|
||||
class TestMenuLogin(EvenniaCommandTest):
|
||||
def test_cmdunloggedlook(self):
|
||||
self.call(menu_login.CmdUnloggedinLook(), "", "======")
|
||||
|
|
|
|||
|
|
@ -3,17 +3,17 @@ Legacy Mux comms tests (extracted from 0.9.5)
|
|||
|
||||
"""
|
||||
|
||||
from evennia.commands.default.tests import CommandTest
|
||||
from evennia.commands.default.tests import EvenniaCommandTest
|
||||
from . import mux_comms_cmds as comms
|
||||
|
||||
|
||||
class TestLegacyMuxComms(CommandTest):
|
||||
class TestLegacyMuxComms(EvenniaCommandTest):
|
||||
"""
|
||||
Test the legacy comms contrib.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(CommandTest, self).setUp()
|
||||
super().setUp()
|
||||
self.call(
|
||||
comms.CmdChannelCreate(),
|
||||
"testchan;test=Test Channel",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ Test of the Unixcommand.
|
|||
|
||||
"""
|
||||
|
||||
from evennia.commands.default.tests import CommandTest
|
||||
from evennia.commands.default.tests import EvenniaCommandTest
|
||||
from .unixcommand import UnixCommand
|
||||
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ class CmdDummy(UnixCommand):
|
|||
self.msg("{} * {} = {}".format(nb1, nb2, result))
|
||||
|
||||
|
||||
class TestUnixCommand(CommandTest):
|
||||
class TestUnixCommand(EvenniaCommandTest):
|
||||
def test_success(self):
|
||||
"""See the command parsing succeed."""
|
||||
self.call(CmdDummy(), "5 10", "5 * 10 = 50")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
"""
|
||||
Complete game implementations/engines.
|
||||
|
||||
"""
|
||||
|
|
@ -3,11 +3,11 @@ Evscaperoom - Griatch 2019
|
|||
|
||||
"""
|
||||
|
||||
from .evscaperoom import commands # noqa
|
||||
from .evscaperoom import menu # noqa
|
||||
from .evscaperoom import objects # noqa
|
||||
from .evscaperoom import room # noqa
|
||||
from .evscaperoom import scripts # noqa
|
||||
from .evscaperoom import state # noqa
|
||||
from .evscaperoom import tests # noqa
|
||||
from .evscaperoom import utils # noqa
|
||||
from . import commands # noqa
|
||||
from . import menu # noqa
|
||||
from . import objects # noqa
|
||||
from . import room # noqa
|
||||
from . import scripts # noqa
|
||||
from . import state # noqa
|
||||
from . import tests # noqa
|
||||
from . import utils # noqa
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ Just start this global script manually or at server creation.
|
|||
|
||||
from evennia import DefaultScript
|
||||
|
||||
from evscaperoom.room import EvscapeRoom
|
||||
from .room import EvscapeRoom
|
||||
|
||||
|
||||
class CleanupScript(DefaultScript):
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ Unit tests for the Evscaperoom
|
|||
import inspect
|
||||
import pkgutil
|
||||
from os import path
|
||||
from evennia.commands.default.tests import CommandTest
|
||||
from evennia.commands.default.tests import EvenniaCommandTest
|
||||
from evennia import InterruptCommand
|
||||
from evennia.utils.test_resources import EvenniaTest
|
||||
from evennia.utils import mod_import
|
||||
|
|
@ -15,7 +15,7 @@ from . import objects
|
|||
from . import utils
|
||||
|
||||
|
||||
class TestEvscaperoomCommands(CommandTest):
|
||||
class TestEvscaperoomCommands(EvenniaCommandTest):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.room1 = utils.create_evscaperoom_object("evscaperoom.room.EvscapeRoom", key="Testroom")
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@ Test the contrib barter system
|
|||
"""
|
||||
|
||||
from mock import Mock
|
||||
from evennia.commands.default.tests import CommandTest
|
||||
from evennia.commands.default.tests import EvenniaCommandTest
|
||||
from evennia.utils.create import create_object
|
||||
from . import barter
|
||||
|
||||
|
||||
class TestBarter(CommandTest):
|
||||
class TestBarter(EvenniaCommandTest):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.tradeitem1 = create_object(key="TradeItem1", location=self.char1)
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@ Testing clothing contrib
|
|||
|
||||
"""
|
||||
|
||||
from evennia.commands.default.tests import CommandTest
|
||||
from evennia.commands.default.tests import EvenniaCommandTest
|
||||
from evennia.utils.create import create_object
|
||||
from evennia.objects.objects import DefaultRoom
|
||||
from evennia.utils.test_resources import EvenniaTest
|
||||
from . import clothing
|
||||
|
||||
|
||||
class TestClothingCmd(CommandTest):
|
||||
class TestClothingCmd(EvenniaCommandTest):
|
||||
def test_clothingcommands(self):
|
||||
wearer = create_object(clothing.ClothedCharacter, key="Wearer")
|
||||
friend = create_object(clothing.ClothedCharacter, key="Friend")
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from evennia.utils.test_resources import EvenniaTest
|
|||
from . import cooldowns
|
||||
|
||||
|
||||
@patch("evennia.contrib.game_systems.cooldowns.time.time", return_value=0.0)
|
||||
@patch("evennia.contrib.game_systems.cooldowns.cooldowns.time.time", return_value=0.0)
|
||||
class TestCooldowns(EvenniaTest):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@ Unit tests for the crafting system contrib.
|
|||
from unittest import mock
|
||||
from django.test import override_settings
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from evennia.commands.default.tests import CommandTest
|
||||
from evennia.utils.test_resources import TestCase
|
||||
from evennia.commands.default.tests import EvenniaCommandTest
|
||||
from evennia.utils.test_resources import EvenniaTestCase
|
||||
from evennia.utils.create import create_object
|
||||
from . import crafting, example_recipes
|
||||
|
||||
|
||||
class TestCraftUtils(TestCase):
|
||||
class TestCraftUtils(EvenniaTestCase):
|
||||
"""
|
||||
Test helper utils for crafting.
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ class _TestMaterial:
|
|||
return self.name
|
||||
|
||||
|
||||
class TestCraftingRecipeBase(TestCase):
|
||||
class TestCraftingRecipeBase(EvenniaTestCase):
|
||||
"""
|
||||
Test the parent recipe class.
|
||||
"""
|
||||
|
|
@ -137,7 +137,7 @@ class _MockRecipe(crafting.CraftingRecipe):
|
|||
|
||||
|
||||
@override_settings(CRAFT_RECIPE_MODULES=[])
|
||||
class TestCraftingRecipe(TestCase):
|
||||
class TestCraftingRecipe(EvenniaTestCase):
|
||||
"""
|
||||
Test the CraftingRecipe class with one recipe
|
||||
"""
|
||||
|
|
@ -474,7 +474,7 @@ class TestCraftingRecipe(TestCase):
|
|||
self.assertIsNotNone(self.tool2.pk)
|
||||
|
||||
|
||||
class TestCraftSword(TestCase):
|
||||
class TestCraftSword(EvenniaTestCase):
|
||||
"""
|
||||
Test the `craft` function by crafting the example sword.
|
||||
|
||||
|
|
@ -655,7 +655,7 @@ class TestCraftSword(TestCase):
|
|||
@mock.patch("evennia.contrib.game_systems.crafting.crafting._load_recipes", new=mock.MagicMock())
|
||||
@mock.patch("evennia.contrib.game_systems.crafting.crafting._RECIPE_CLASSES", new={"testrecipe": _MockRecipe})
|
||||
@override_settings(CRAFT_RECIPE_MODULES=[], DEFAULT_HOME="#999999")
|
||||
class TestCraftCommand(CommandTest):
|
||||
class TestCraftCommand(EvenniaCommandTest):
|
||||
"""Test the crafting command"""
|
||||
|
||||
def setUp(self):
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@ Test gendersub contrib.
|
|||
"""
|
||||
|
||||
|
||||
from evennia.commands.default.tests import CommandTest
|
||||
from evennia.commands.default.tests import EvenniaCommandTest
|
||||
from evennia.utils.create import create_object
|
||||
from mock import patch
|
||||
from . import gendersub
|
||||
|
||||
|
||||
class TestGenderSub(CommandTest):
|
||||
class TestGenderSub(EvenniaCommandTest):
|
||||
def test_setgender(self):
|
||||
self.call(gendersub.SetGender(), "male", "Your gender was set to male.")
|
||||
self.call(gendersub.SetGender(), "ambiguous", "Your gender was set to ambiguous.")
|
||||
|
|
@ -22,7 +22,7 @@ class TestGenderSub(CommandTest):
|
|||
self.assertEqual(
|
||||
gendersub._RE_GENDER_PRONOUN.sub(char._get_pronoun, txt), "Test their gender"
|
||||
)
|
||||
with patch("evennia.contrib.game_systems.gendersub.DefaultCharacter.msg") as mock_msg:
|
||||
with patch("evennia.contrib.game_systems.gendersub.gendersub.DefaultCharacter.msg") as mock_msg:
|
||||
char.db.gender = "female"
|
||||
char.msg("Test |p gender")
|
||||
mock_msg.assert_called_with("Test her gender", from_obj=None, session=None)
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@ Test mail contrib
|
|||
|
||||
"""
|
||||
|
||||
from evennia.commands.default.tests import CommandTest
|
||||
from evennia.commands.default.tests import EvenniaCommandTest
|
||||
from . import mail
|
||||
|
||||
|
||||
class TestMail(CommandTest):
|
||||
class TestMail(EvenniaCommandTest):
|
||||
def test_mail(self):
|
||||
self.call(mail.CmdMail(), "2", "'2' is not a valid mail id.", caller=self.account)
|
||||
self.call(mail.CmdMail(), "test", "'test' is not a valid mail id.", caller=self.account)
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@ Test multidescer contrib.
|
|||
|
||||
"""
|
||||
|
||||
from evennia.commands.default.tests import CommandTest
|
||||
from evennia.commands.default.tests import EvenniaCommandTest
|
||||
from . import multidescer
|
||||
|
||||
|
||||
class TestMultidescer(CommandTest):
|
||||
class TestMultidescer(EvenniaCommandTest):
|
||||
def test_cmdmultidesc(self):
|
||||
self.call(multidescer.CmdMultiDesc(), "/list", "Stored descs:\ncaller:")
|
||||
self.call(
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ import re
|
|||
import itertools
|
||||
from mock import Mock
|
||||
from evennia.utils import search
|
||||
from evennia.commands.default.tests import CommandTest
|
||||
from evennia.commands.default.tests import EvenniaCommandTest
|
||||
from evennia.utils.create import create_object
|
||||
from . import puzzles
|
||||
|
||||
|
||||
class TestPuzzles(CommandTest):
|
||||
class TestPuzzles(EvenniaCommandTest):
|
||||
def setUp(self):
|
||||
super(TestPuzzles, self).setUp()
|
||||
self.steel = create_object(self.object_typeclass, key="steel", location=self.char1.location)
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@ Turnbattle tests.
|
|||
"""
|
||||
|
||||
from mock import patch, MagicMock
|
||||
from evennia.commands.default.tests import CommandTest
|
||||
from evennia.commands.default.tests import EvenniaCommandTest
|
||||
from evennia.utils.create import create_object
|
||||
from evennia.utils.test_resources import EvenniaTest
|
||||
from evennia.objects.objects import DefaultRoom
|
||||
from . import tb_basic, tb_equip, tb_range, tb_items, tb_magic
|
||||
|
||||
|
||||
class TestTurnBattleBasicCmd(CommandTest):
|
||||
class TestTurnBattleBasicCmd(EvenniaCommandTest):
|
||||
|
||||
# Test basic combat commands
|
||||
def test_turnbattlecmd(self):
|
||||
|
|
@ -22,7 +22,7 @@ class TestTurnBattleBasicCmd(CommandTest):
|
|||
self.call(tb_basic.CmdRest(), "", "Char rests to recover HP.")
|
||||
|
||||
|
||||
class TestTurnBattleEquipCmd(CommandTest):
|
||||
class TestTurnBattleEquipCmd(EvenniaCommandTest):
|
||||
def setUp(self):
|
||||
super(TestTurnBattleEquipCmd, self).setUp()
|
||||
self.testweapon = create_object(tb_equip.TBEWeapon, key="test weapon")
|
||||
|
|
@ -45,7 +45,7 @@ class TestTurnBattleEquipCmd(CommandTest):
|
|||
self.call(tb_equip.CmdRest(), "", "Char rests to recover HP.")
|
||||
|
||||
|
||||
class TestTurnBattleRangeCmd(CommandTest):
|
||||
class TestTurnBattleRangeCmd(EvenniaCommandTest):
|
||||
# Test range commands
|
||||
def test_turnbattlerangecmd(self):
|
||||
# Start with range module specific commands.
|
||||
|
|
@ -61,7 +61,7 @@ class TestTurnBattleRangeCmd(CommandTest):
|
|||
self.call(tb_range.CmdRest(), "", "Char rests to recover HP.")
|
||||
|
||||
|
||||
class TestTurnBattleItemsCmd(CommandTest):
|
||||
class TestTurnBattleItemsCmd(EvenniaCommandTest):
|
||||
def setUp(self):
|
||||
super(TestTurnBattleItemsCmd, self).setUp()
|
||||
self.testitem = create_object(key="test item")
|
||||
|
|
@ -78,7 +78,7 @@ class TestTurnBattleItemsCmd(CommandTest):
|
|||
self.call(tb_items.CmdRest(), "", "Char rests to recover HP.")
|
||||
|
||||
|
||||
class TestTurnBattleMagicCmd(CommandTest):
|
||||
class TestTurnBattleMagicCmd(EvenniaCommandTest):
|
||||
|
||||
# Test magic commands
|
||||
def test_turnbattlemagiccmd(self):
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ Testing of ExtendedRoom contrib
|
|||
import datetime
|
||||
from mock import patch, Mock
|
||||
from django.conf import settings
|
||||
from evennia.commands.default.tests import CommandTest
|
||||
from evennia.commands.default.tests import EvenniaCommandTest
|
||||
from evennia.objects.objects import DefaultRoom
|
||||
from . import extended_room
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ class ForceUTCDatetime(datetime.datetime):
|
|||
@patch("evennia.contrib.grid.extended_room.extended_room.datetime.datetime", ForceUTCDatetime)
|
||||
# mock gametime to return April 9, 2064, at 21:06 (spring evening)
|
||||
@patch("evennia.utils.gametime.gametime", new=Mock(return_value=2975000766))
|
||||
class TestExtendedRoom(CommandTest):
|
||||
class TestExtendedRoom(EvenniaCommandTest):
|
||||
room_typeclass = extended_room.ExtendedRoom
|
||||
DETAIL_DESC = "A test detail."
|
||||
SPRING_DESC = "A spring description."
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ Test map builder.
|
|||
|
||||
"""
|
||||
|
||||
from evennia.commands.default.tests import CommandTest
|
||||
from evennia.commands.default.tests import EvenniaCommandTest
|
||||
from . import mapbuilder
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
|
@ -187,7 +187,7 @@ EXAMPLE2_LEGEND = {
|
|||
}
|
||||
|
||||
|
||||
class TestMapBuilder(CommandTest):
|
||||
class TestMapBuilder(EvenniaCommandTest):
|
||||
def test_cmdmapbuilder(self):
|
||||
self.call(
|
||||
mapbuilder.CmdMapBuilder(),
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ Tests of simpledoor.
|
|||
"""
|
||||
|
||||
|
||||
from evennia.commands.default.tests import CommandTest
|
||||
from evennia.commands.default.tests import EvenniaCommandTest
|
||||
from . import simpledoor
|
||||
|
||||
|
||||
class TestSimpleDoor(CommandTest):
|
||||
class TestSimpleDoor(EvenniaCommandTest):
|
||||
def test_cmdopen(self):
|
||||
self.call(
|
||||
simpledoor.CmdOpen(),
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ Slow exit tests.
|
|||
"""
|
||||
|
||||
from mock import Mock, patch
|
||||
from evennia.commands.default.tests import CommandTest
|
||||
from evennia.commands.default.tests import EvenniaCommandTest
|
||||
from evennia.utils.create import create_object
|
||||
from . import slow_exit
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ def _cancellable_mockdelay(time, callback, *args, **kwargs):
|
|||
return Mock()
|
||||
|
||||
|
||||
class TestSlowExit(CommandTest):
|
||||
class TestSlowExit(EvenniaCommandTest):
|
||||
@patch("evennia.utils.delay", _cancellable_mockdelay)
|
||||
def test_exit(self):
|
||||
exi = create_object(
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@ Testing of TestDice.
|
|||
|
||||
"""
|
||||
|
||||
from evennia.commands.default.tests import CommandTest
|
||||
from evennia.commands.default.tests import EvenniaCommandTest
|
||||
from mock import patch
|
||||
from . import dice
|
||||
|
||||
|
||||
@patch("evennia.contrib.dice.randint", return_value=5)
|
||||
class TestDice(CommandTest):
|
||||
@patch("evennia.contrib.rpg.dice.dice.randint", return_value=5)
|
||||
class TestDice(EvenniaCommandTest):
|
||||
def test_roll_dice(self, mocked_randint):
|
||||
self.assertEqual(dice.roll_dice(6, 6, modifier=("+", 4)), mocked_randint() * 6 + 4)
|
||||
self.assertEqual(dice.roll_dice(6, 6, conditional=("<", 35)), True)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ Tests for RP system
|
|||
"""
|
||||
import time
|
||||
from anything import Anything
|
||||
from evennia.commands.default.tests import CommandTest
|
||||
from evennia.commands.default.tests import EvenniaCommandTest
|
||||
from evennia.utils.test_resources import EvenniaTest
|
||||
from evennia import create_object
|
||||
|
||||
|
|
@ -278,7 +278,7 @@ class TestRPSystem(EvenniaTest):
|
|||
self.assertEqual(result, (Anything, self.speaker, self.speaker.key))
|
||||
|
||||
|
||||
class TestRPSystemCommands(CommandTest):
|
||||
class TestRPSystemCommands(EvenniaCommandTest):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.char1.swap_typeclass(rpsystem.ContribRPCharacter)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ Unit test module for Trait classes.
|
|||
from copy import copy
|
||||
from anything import Something
|
||||
from mock import MagicMock, patch
|
||||
from django.test import TestCase
|
||||
from evennia.utils.test_resources import EvenniaTestCase
|
||||
from . import traits
|
||||
|
||||
|
||||
|
|
@ -39,10 +39,10 @@ _TEST_TRAIT_CLASS_PATHS = [
|
|||
]
|
||||
|
||||
|
||||
class _TraitHandlerBase(TestCase):
|
||||
class _TraitHandlerBase(EvenniaTestCase):
|
||||
"Base for trait tests"
|
||||
|
||||
@patch("evennia.contrib.rpg.traits._TRAIT_CLASS_PATHS", new=_TEST_TRAIT_CLASS_PATHS)
|
||||
@patch("evennia.contrib.rpg.traits.traits._TRAIT_CLASS_PATHS", new=_TEST_TRAIT_CLASS_PATHS)
|
||||
def setUp(self):
|
||||
self.obj = _MockObj()
|
||||
self.traithandler = traits.TraitHandler(self.obj)
|
||||
|
|
@ -494,7 +494,7 @@ class TestTraitCounterTimed(_TraitHandlerBase):
|
|||
Test for trait with timer component
|
||||
"""
|
||||
|
||||
@patch("evennia.contrib.rpg.traits.time", new=MagicMock(return_value=1000))
|
||||
@patch("evennia.contrib.rpg.traits.traits.time", new=MagicMock(return_value=1000))
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.traithandler.add(
|
||||
|
|
@ -522,7 +522,7 @@ class TestTraitCounterTimed(_TraitHandlerBase):
|
|||
self.trait.ratetarget,
|
||||
)
|
||||
|
||||
@patch("evennia.contrib.rpg.traits.time")
|
||||
@patch("evennia.contrib.rpg.traits.traits.time")
|
||||
def test_timer_rate(self, mock_time):
|
||||
"""Test time stepping"""
|
||||
mock_time.return_value = 1000
|
||||
|
|
@ -549,7 +549,7 @@ class TestTraitCounterTimed(_TraitHandlerBase):
|
|||
mock_time.return_value = 1218
|
||||
self.assertEqual(self._get_timer_data(), (0, -2, -10, None, None))
|
||||
|
||||
@patch("evennia.contrib.rpg.traits.time")
|
||||
@patch("evennia.contrib.rpg.traits.traits.time")
|
||||
def test_timer_ratetarget(self, mock_time):
|
||||
"""test ratetarget"""
|
||||
mock_time.return_value = 1000
|
||||
|
|
@ -751,7 +751,7 @@ class TestTraitGaugeTimed(_TraitHandlerBase):
|
|||
Test for trait with timer component
|
||||
"""
|
||||
|
||||
@patch("evennia.contrib.rpg.traits.time", new=MagicMock(return_value=1000))
|
||||
@patch("evennia.contrib.rpg.traits.traits.time", new=MagicMock(return_value=1000))
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.traithandler.add(
|
||||
|
|
@ -778,7 +778,7 @@ class TestTraitGaugeTimed(_TraitHandlerBase):
|
|||
self.trait.ratetarget,
|
||||
)
|
||||
|
||||
@patch("evennia.contrib.rpg.traits.time")
|
||||
@patch("evennia.contrib.rpg.traits.traits.time")
|
||||
def test_timer_rate(self, mock_time):
|
||||
"""Test time stepping"""
|
||||
mock_time.return_value = 1000
|
||||
|
|
@ -806,7 +806,7 @@ class TestTraitGaugeTimed(_TraitHandlerBase):
|
|||
mock_time.return_value = 1218
|
||||
self.assertEqual(self._get_timer_data(), (0, 0, -10, None, None))
|
||||
|
||||
@patch("evennia.contrib.rpg.traits.time")
|
||||
@patch("evennia.contrib.rpg.traits.traits.time")
|
||||
def test_timer_ratetarget(self, mock_time):
|
||||
"""test ratetarget"""
|
||||
mock_time.return_value = 1000
|
||||
|
|
@ -826,7 +826,7 @@ class TestTraitGaugeTimed(_TraitHandlerBase):
|
|||
self.assertEqual(self._get_timer_data(), (70, 70, 1, None, 70))
|
||||
|
||||
|
||||
class TestNumericTraitOperators(TestCase):
|
||||
class TestNumericTraitOperators(EvenniaTestCase):
|
||||
"""Test case for numeric magic method implementations."""
|
||||
|
||||
def setUp(self):
|
||||
|
|
@ -909,13 +909,13 @@ class DummyCharacter(_MockObj):
|
|||
health = traits.TraitProperty("Health value", trait_type="gauge", base=100)
|
||||
|
||||
|
||||
class TestTraitFields(TestCase):
|
||||
class TestTraitFields(EvenniaTestCase):
|
||||
"""
|
||||
Test the TraitField class.
|
||||
|
||||
"""
|
||||
|
||||
@patch("evennia.contrib.rpg.traits._TRAIT_CLASS_PATHS", new=_TEST_TRAIT_CLASS_PATHS)
|
||||
@patch("evennia.contrib.rpg.traits.traits._TRAIT_CLASS_PATHS", new=_TEST_TRAIT_CLASS_PATHS)
|
||||
def test_traitfields(self):
|
||||
obj = DummyCharacter()
|
||||
obj2 = DummyCharacter()
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from evennia.utils.test_resources import EvenniaTest
|
|||
from .bodyfunctions import BodyFunctions
|
||||
|
||||
|
||||
@patch("evennia.contrib.tutorials.bodyfunctions.random")
|
||||
@patch("evennia.contrib.tutorials.bodyfunctions.bodyfunctions.random")
|
||||
class TestBodyFunctions(EvenniaTest):
|
||||
script_typeclass = BodyFunctions
|
||||
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
Tutorial - talking NPC tests.
|
||||
|
||||
"""
|
||||
from evennia.commands.default.tests import CommandTest
|
||||
from evennia.commands.default.tests import EvenniaCommandTest
|
||||
from evennia.utils.create import create_object
|
||||
from . import talking_npc
|
||||
|
||||
|
||||
class TestTalkingNPC(CommandTest):
|
||||
class TestTalkingNPC(EvenniaCommandTest):
|
||||
def test_talkingnpc(self):
|
||||
npc = create_object(talking_npc.TalkingNPC, key="npctalker", location=self.room1)
|
||||
self.call(talking_npc.CmdTalk(), "", "(You walk up and talk to Char.)")
|
||||
|
|
|
|||
|
|
@ -4,4 +4,4 @@ Tutorial world - Griatch, 2011, 2015
|
|||
|
||||
"""
|
||||
|
||||
from . import mob, objects, rooms # noqa
|
||||
from . import mob, objects, rooms, intro_menu # noqa
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ Test tutorial_world/mob
|
|||
from mock import patch
|
||||
from twisted.trial.unittest import TestCase as TwistedTestCase
|
||||
from twisted.internet.base import DelayedCall
|
||||
from evennia.commands.default.tests import CommandTest
|
||||
from evennia.commands.default.tests import EvenniaCommandTest
|
||||
from evennia.utils.create import create_object
|
||||
from evennia.utils.test_resources import EvenniaTest, mockdelay, mockdeferLater
|
||||
from . import mob, objects as tutobjects, rooms as tutrooms
|
||||
|
|
@ -30,7 +30,7 @@ class TestTutorialWorldMob(EvenniaTest):
|
|||
DelayedCall.debug = True
|
||||
|
||||
|
||||
class TestTutorialWorldObjects(TwistedTestCase, CommandTest):
|
||||
class TestTutorialWorldObjects(TwistedTestCase, EvenniaCommandTest):
|
||||
def test_tutorialobj(self):
|
||||
obj1 = create_object(tutobjects.TutorialObject, key="tutobj")
|
||||
obj1.reset()
|
||||
|
|
@ -129,7 +129,7 @@ class TestTutorialWorldObjects(TwistedTestCase, CommandTest):
|
|||
self.call(tutobjects.CmdGetWeapon(), "", "You find Rusty sword.", obj=rack)
|
||||
|
||||
|
||||
class TestTutorialWorldRooms(CommandTest):
|
||||
class TestTutorialWorldRooms(EvenniaCommandTest):
|
||||
def test_cmdtutorial(self):
|
||||
room = create_object(tutrooms.TutorialRoom, key="tutroom")
|
||||
self.char1.location = room
|
||||
|
|
|
|||
|
|
@ -4,20 +4,16 @@ Module containing the test cases for the Audit system.
|
|||
"""
|
||||
|
||||
from anything import Anything
|
||||
from django.conf import settings
|
||||
from django.test import override_settings
|
||||
from evennia.utils.test_resources import EvenniaTest
|
||||
import re
|
||||
|
||||
# Configure session auditing settings - TODO: This is bad practice that leaks over to other tests
|
||||
settings.AUDIT_CALLBACK = "evennia.contrib.utils.auditing.outputs.to_syslog"
|
||||
settings.AUDIT_IN = True
|
||||
settings.AUDIT_OUT = True
|
||||
settings.AUDIT_ALLOW_SPARSE = True
|
||||
|
||||
# Configure settings to use custom session - TODO: This is bad practice, changing global settings
|
||||
settings.SERVER_SESSION_CLASS = "evennia.contrib.utils.auditing.server.AuditedServerSession"
|
||||
|
||||
|
||||
@override_settings(
|
||||
AUDIT_CALLBACK="evennia.contrib.utils.auditing.outputs.to_syslog",
|
||||
AUDIT_IN=True,
|
||||
AUDIT_OUT=True,
|
||||
AUDIT_ALLOW_SPARSE=True)
|
||||
class AuditingTest(EvenniaTest):
|
||||
def test_mask(self):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -4,3 +4,5 @@ Pseudo-random generator - vlgeoff 2017
|
|||
"""
|
||||
|
||||
from .random_string_generator import RandomStringGenerator # noqa
|
||||
from .random_string_generator import RandomStringGeneratorScript # noqa
|
||||
from .random_string_generator import RejectedRegex, ExhaustedGenerator # noqa
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ Random string tests.
|
|||
"""
|
||||
|
||||
from evennia.utils.test_resources import EvenniaTest
|
||||
from evennia.contrib import random_string_generator
|
||||
from . import random_string_generator
|
||||
|
||||
SIMPLE_GENERATOR = random_string_generator.RandomStringGenerator("simple", "[01]{2}")
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ Test tree select
|
|||
"""
|
||||
|
||||
from evennia.utils.test_resources import EvenniaTest
|
||||
from evennia.contrib import tree_select
|
||||
from evennia.contrib import fieldfill
|
||||
from . import tree_select
|
||||
from evennia.contrib.utils.fieldfill import fieldfill
|
||||
|
||||
TREE_MENU_TESTSTR = """Foo
|
||||
Bar
|
||||
|
|
|
|||
|
|
@ -508,7 +508,11 @@ TYPECLASS_PATHS = [
|
|||
"typeclasses",
|
||||
"evennia",
|
||||
"evennia.contrib",
|
||||
"evennia.contrib.game_systems",
|
||||
"evennia.contrib.base_systems",
|
||||
"evennia.contrib.full_systems",
|
||||
"evennia.contrib.tutorials",
|
||||
"evennia.contrib.utils",
|
||||
]
|
||||
|
||||
# Typeclass for account objects (linked to a character) (fallback)
|
||||
|
|
@ -671,7 +675,8 @@ FUNCPARSER_PARSE_OUTGOING_MESSAGES_ENABLED = False
|
|||
FUNCPARSER_OUTGOING_MESSAGES_MODULES = ["evennia.utils.funcparser", "server.conf.inlinefuncs"]
|
||||
# Prototype values are also parsed with FuncParser. These modules
|
||||
# define which $func callables are available to use in prototypes.
|
||||
FUNCPARSER_PROTOTYPE_PARSING_MODULES = ["evennia.prototypes.protfuncs", "server.conf.prototypefuncs"]
|
||||
FUNCPARSER_PROTOTYPE_PARSING_MODULES = ["evennia.prototypes.protfuncs",
|
||||
"server.conf.prototypefuncs"]
|
||||
|
||||
######################################################################
|
||||
# Global Scripts
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ Various helper resources for writing unittests.
|
|||
import sys
|
||||
from twisted.internet.defer import Deferred
|
||||
from django.conf import settings
|
||||
from django.test import TestCase
|
||||
from django.test import TestCase, override_settings
|
||||
from mock import Mock, patch
|
||||
from evennia.objects.objects import DefaultObject, DefaultCharacter, DefaultRoom, DefaultExit
|
||||
from evennia.accounts.accounts import DefaultAccount
|
||||
|
|
@ -14,6 +14,57 @@ from evennia.server.serversession import ServerSession
|
|||
from evennia.server.sessionhandler import SESSIONS
|
||||
from evennia.utils import create
|
||||
from evennia.utils.idmapper.models import flush_cache
|
||||
from evennia.utils.utils import all_from_module
|
||||
from evennia import settings_default
|
||||
|
||||
|
||||
# set up a 'pristine' setting, unaffected by any changes in mygame
|
||||
DEFAULT_SETTING_RESETS = dict(
|
||||
CONNECTION_SCREEN_MODULE="evennia.game_template.server.conf.connection_screens",
|
||||
AT_SERVER_STARTSTOP_MODULE="evennia.game_template.server.conf.at_server_startstop",
|
||||
AT_SERVICES_PLUGINS_MODULES=["evennia.game_template.server.conf.server_services_plugins"],
|
||||
PORTAL_SERVICES_PLUGIN_MODULES=["evennia.game_template.server.conf.portal_services_plugins"],
|
||||
MSSP_META_MODULE="evennia.game_template.server.conf.mssp",
|
||||
WEB_PLUGINS_MODULE="server.conf.web_plugins",
|
||||
LOCK_FUNC_MODULES=("evennia.locks.lockfuncs", "evennia.game_template.server.conf.lockfuncs"),
|
||||
INPUT_FUNC_MODULES=["evennia.server.inputfuncs",
|
||||
"evennia.game_template.server.conf.inputfuncs"],
|
||||
PROTOTYPE_MODULES=["evennia.game_template.world.prototypes"],
|
||||
CMDSET_UNLOGGEDIN="evennia.game_template.commands.default_cmdsets.UnloggedinCmdSet",
|
||||
CMDSET_SESSION="evennia.game_template.commands.default_cmdsets.SessionCmdSet",
|
||||
CMDSET_CHARACTER="evennia.game_template.commands.default_cmdsets.CharacterCmdSet",
|
||||
CMDSET_ACCOUNT="evennia.game_template.commands.default_cmdsets.AccountCmdSet",
|
||||
CMDSET_PATHS=["evennia.game_template.commands", "evennia", "evennia.contrib"],
|
||||
TYPECLASS_PATHS=[
|
||||
"evennia",
|
||||
"evennia.contrib",
|
||||
"evennia.contrib.game_systems",
|
||||
"evennia.contrib.base_systems",
|
||||
"evennia.contrib.full_systems",
|
||||
"evennia.contrib.tutorials",
|
||||
"evennia.contrib.utils"],
|
||||
BASE_ACCOUNT_TYPECLASS="evennia.accounts.accounts.DefaultAccount",
|
||||
BASE_OBJECT_TYPECLASS="evennia.objects.objects.DefaultObject",
|
||||
BASE_CHARACTER_TYPECLASS="evennia.objects.objects.DefaultCharacter",
|
||||
BASE_ROOM_TYPECLASS="evennia.objects.objects.DefaultRoom",
|
||||
BASE_EXIT_TYPECLASS="evennia.objects.objects.DefaultExit",
|
||||
BASE_CHANNEL_TYPECLASS="evennia.comms.comms.DefaultChannel",
|
||||
BASE_SCRIPT_TYPECLASS="evennia.scripts.scripts.DefaultScript",
|
||||
BASE_BATCHPROCESS_PATHS=["evennia.game_template.world",
|
||||
"evennia.contrib", "evennia.contrib.tutorials"],
|
||||
FILE_HELP_ENTRY_MODULES=["evennia.game_template.world.help_entries"],
|
||||
FUNCPARSER_OUTGOING_MESSAGES_MODULES=["evennia.utils.funcparser",
|
||||
"evennia.game_template.server.conf.inlinefuncs"],
|
||||
FUNCPARSER_PROTOTYPE_PARSING_MODULES=["evennia.prototypes.protfuncs",
|
||||
"evennia.game_template.server.conf.prototypefuncs"],
|
||||
BASE_GUEST_TYPECLASS="evennia.accounts.accounts.DefaultGuest",
|
||||
)
|
||||
|
||||
DEFAULT_SETTINGS = {
|
||||
**all_from_module(settings_default),
|
||||
**DEFAULT_SETTING_RESETS
|
||||
}
|
||||
DEFAULT_SETTINGS.pop("DATABASES") # we want different dbs tested in CI
|
||||
|
||||
|
||||
# mocking of evennia.utils.utils.delay
|
||||
|
|
@ -69,9 +120,9 @@ def _mock_deferlater(reactor, timedelay, callback, *args, **kwargs):
|
|||
return Deferred()
|
||||
|
||||
|
||||
class EvenniaTest(TestCase):
|
||||
class EvenniaTestMixin:
|
||||
"""
|
||||
Base test for Evennia, sets up a basic environment.
|
||||
Evennia test environment mixin
|
||||
"""
|
||||
|
||||
account_typeclass = DefaultAccount
|
||||
|
|
@ -161,10 +212,29 @@ class EvenniaTest(TestCase):
|
|||
super().tearDown()
|
||||
|
||||
|
||||
class LocalEvenniaTest(EvenniaTest):
|
||||
@override_settings(**DEFAULT_SETTINGS)
|
||||
class EvenniaTestCase(TestCase):
|
||||
"""
|
||||
Base test (with no default objects) but with
|
||||
enforced default settings.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
@override_settings(**DEFAULT_SETTINGS)
|
||||
class EvenniaTest(EvenniaTestMixin, TestCase):
|
||||
"""
|
||||
This class parent uses only default settings.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
class LocalEvenniaTest(EvenniaTestMixin, TestCase):
|
||||
"""
|
||||
This test class is intended for inheriting in mygame tests.
|
||||
It helps ensure your tests are run with your own objects.
|
||||
It helps ensure your tests are run with your own objects
|
||||
and settings from your game folder.
|
||||
|
||||
"""
|
||||
|
||||
account_typeclass = settings.BASE_ACCOUNT_TYPECLASS
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue