mirror of
https://github.com/evennia/evennia.git
synced 2026-04-02 22:17:17 +02:00
Updated and cleaned the wiki2rest converter. The ReST documentation should look a lot better now, with less weirdness. Using a python google-code snippet to convert now, so no more need for third-party ruby downloads! This should transfer to readthedocs shortly.
This commit is contained in:
parent
43f16094c1
commit
ae0f7a04c5
55 changed files with 3990 additions and 1778 deletions
|
|
@ -1,3 +1,5 @@
|
|||
Using and writing unit tests for Evennia.
|
||||
|
||||
Unit Testing
|
||||
============
|
||||
|
||||
|
|
@ -24,7 +26,7 @@ Running the test suite
|
|||
To run the Evennia test suite, go to the ``game/`` folder and issue the
|
||||
command
|
||||
|
||||
``python manage.py test``
|
||||
``python manage.py test``
|
||||
|
||||
A temporary database will be instantiated to manage the tests. If
|
||||
everything works out you will see how many tests were run and how long
|
||||
|
|
@ -46,8 +48,8 @@ used to test a single aspect or component in various ways. Each test
|
|||
case contains one ore more *test methods* - these define the actual
|
||||
tests to run. You can name the test methods anything you want as long as
|
||||
the name starts with "``test_``\ ". Your ``TestCase`` class can also
|
||||
have a method !SetUp(). This is run before each test, setting up
|
||||
whatever preparations the test methods need.
|
||||
have a method SetUp(). This is run before each test, setting up whatever
|
||||
preparations the test methods need.
|
||||
|
||||
To test the results, you use special methods of the ``TestCase`` class.
|
||||
Many of those start with "``assert``\ ", such as ``assertEqual`` or
|
||||
|
|
@ -57,7 +59,34 @@ Example of a ``TestCase`` class (inside a file ``tests.py``):
|
|||
|
||||
::
|
||||
|
||||
# testing a simple funciontry: # this is an optimized version only available in later Django versions from django.utils.unittest import TestCase except ImportError: # if the first fail, we use the old version from django.test import TestCase# the function we want to test from mypath import myfuncTestObj(unittest.TestCase): "This tests a function myfunc." def test_return_value(self): "test method. Makes sure return value is as expected." expected_return = "This is me being nice." actual_return = myfunc() # test self.assertEqual(expected_return, actual_return) def test_alternative_call(self): "test method. Calls with a keyword argument." expected_return = "This is me being baaaad." actual_return = myfunc(bad=True) # test self.assertEqual(expected_return, actual_return)
|
||||
|
||||
# testing a simple funcion
|
||||
|
||||
try:
|
||||
# this is an optimized version only available in later Django versions
|
||||
from django.utils.unittest import TestCase
|
||||
except ImportError:
|
||||
# if the first fail, we use the old version
|
||||
from django.test import TestCase
|
||||
|
||||
# the function we want to test
|
||||
from mypath import myfunc
|
||||
|
||||
TestObj(unittest.TestCase):
|
||||
"This tests a function myfunc."
|
||||
|
||||
def test_return_value(self):
|
||||
"test method. Makes sure return value is as expected."
|
||||
expected_return = "This is me being nice."
|
||||
actual_return = myfunc()
|
||||
# test
|
||||
self.assertEqual(expected_return, actual_return)
|
||||
def test_alternative_call(self):
|
||||
"test method. Calls with a keyword argument."
|
||||
expected_return = "This is me being baaaad."
|
||||
actual_return = myfunc(bad=True)
|
||||
# test
|
||||
self.assertEqual(expected_return, actual_return)
|
||||
|
||||
The above example is very simplistic, but you should get the idea. Look
|
||||
at ``src/objects/tests.py`` for more realistic examples of tests. You
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue