mirror of
https://github.com/evennia/evennia.git
synced 2026-03-25 01:06:32 +01:00
Implemented a unit testing framework for Evennia. Unfortunately it seems it is only usable in latest Django SVN, due to a Django bug; Run "manage.py test-evennia" - if you get errors about SUPPORTS_TRANSACTIONS, you are affected by the bug. Since this is only likely to affect evennia devs at this point I added a few base tests in src/objects/tests.py as a template for those willing to help add unit tests.
This commit is contained in:
parent
a7899e0119
commit
502ebff1a2
7 changed files with 227 additions and 15 deletions
|
|
@ -264,9 +264,15 @@ def format_multimatches(caller, matches):
|
|||
|
||||
# Main command-handler function
|
||||
|
||||
def cmdhandler(caller, raw_string, unloggedin=False):
|
||||
def cmdhandler(caller, raw_string, unloggedin=False, testing=False):
|
||||
"""
|
||||
This is the main function to handle any string sent to the engine.
|
||||
|
||||
caller - calling object
|
||||
raw_string - the command string given on the command line
|
||||
unloggedin - if caller is an authenticated user or not
|
||||
testing - if we should actually execute the command or not.
|
||||
if True, the command instance will be returned instead.
|
||||
"""
|
||||
try: # catch bugs in cmdhandler itself
|
||||
try: # catch special-type commands
|
||||
|
|
@ -375,7 +381,11 @@ def cmdhandler(caller, raw_string, unloggedin=False):
|
|||
# we make sure to validate its scripts.
|
||||
cmd.obj.scripts.validate()
|
||||
|
||||
# Parse and execute
|
||||
if testing:
|
||||
# only return the command instance
|
||||
return cmd
|
||||
|
||||
# Parse and execute
|
||||
cmd.parse()
|
||||
cmd.func()
|
||||
# Done!
|
||||
|
|
@ -395,6 +405,10 @@ def cmdhandler(caller, raw_string, unloggedin=False):
|
|||
# cmd.obj is automatically made available.
|
||||
# we make sure to validate its scripts.
|
||||
cmd.obj.scripts.validate()
|
||||
|
||||
if testing:
|
||||
# only return the command instance
|
||||
return syscmd
|
||||
|
||||
# parse and run the command
|
||||
syscmd.parse()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue