Further tweaks to unit test systems
This commit is contained in:
parent
67c4896a53
commit
440afe6928
3 changed files with 24 additions and 29 deletions
|
|
@ -1,25 +0,0 @@
|
||||||
"""
|
|
||||||
Test runner for Evennia test suite. Run with "game/manage.py test".
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.test.simple import DjangoTestSuiteRunner
|
|
||||||
|
|
||||||
|
|
||||||
class EvenniaTestSuiteRunner(DjangoTestSuiteRunner):
|
|
||||||
"""
|
|
||||||
This test runner only runs tests on the apps specified in src/ and game/ to
|
|
||||||
avoid running the large number of tests defined by Django
|
|
||||||
"""
|
|
||||||
def build_suite(self, test_labels, extra_tests=None, **kwargs):
|
|
||||||
"""
|
|
||||||
Build a test suite for Evennia. test_labels is a list of apps to test.
|
|
||||||
If not given, a subset of settings.INSTALLED_APPS will be used.
|
|
||||||
"""
|
|
||||||
if not test_labels:
|
|
||||||
test_labels = [applabel.rsplit('.', 1)[1] for applabel in settings.INSTALLED_APPS
|
|
||||||
if (applabel.startswith('src.') or applabel.startswith('game.'))]
|
|
||||||
return super(EvenniaTestSuiteRunner, self).build_suite(test_labels, extra_tests=extra_tests, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -26,15 +26,35 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from src.locks import tests as locktests
|
from django.conf import settings
|
||||||
from src.utils import tests as utiltests
|
from django.test.simple import DjangoTestSuiteRunner
|
||||||
from src.commands.default import tests as commandtests
|
|
||||||
|
|
||||||
|
class EvenniaTestSuiteRunner(DjangoTestSuiteRunner):
|
||||||
|
"""
|
||||||
|
This test runner only runs tests on the apps specified in src/ and game/ to
|
||||||
|
avoid running the large number of tests defined by Django
|
||||||
|
"""
|
||||||
|
def build_suite(self, test_labels, extra_tests=None, **kwargs):
|
||||||
|
"""
|
||||||
|
Build a test suite for Evennia. test_labels is a list of apps to test.
|
||||||
|
If not given, a subset of settings.INSTALLED_APPS will be used.
|
||||||
|
"""
|
||||||
|
if not test_labels:
|
||||||
|
test_labels = [applabel.rsplit('.', 1)[1] for applabel in settings.INSTALLED_APPS
|
||||||
|
if (applabel.startswith('src.') or applabel.startswith('game.'))]
|
||||||
|
return super(EvenniaTestSuiteRunner, self).build_suite(test_labels, extra_tests=extra_tests, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def suite():
|
def suite():
|
||||||
"""
|
"""
|
||||||
This function is called automatically by the django test runner.
|
This function is called automatically by the django test runner.
|
||||||
This also collates tests from packages that are not formally django applications.
|
This also collates tests from packages that are not formally django applications.
|
||||||
"""
|
"""
|
||||||
|
from src.locks import tests as locktests
|
||||||
|
from src.utils import tests as utiltests
|
||||||
|
from src.commands.default import tests as commandtests
|
||||||
|
|
||||||
tsuite = unittest.TestSuite()
|
tsuite = unittest.TestSuite()
|
||||||
tsuite.addTest(unittest.defaultTestLoader.loadTestsFromModule(sys.modules[__name__]))
|
tsuite.addTest(unittest.defaultTestLoader.loadTestsFromModule(sys.modules[__name__]))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -522,7 +522,7 @@ INSTALLED_APPS = (
|
||||||
AUTH_USER_MODEL = "players.PlayerDB"
|
AUTH_USER_MODEL = "players.PlayerDB"
|
||||||
#AUTH_PROFILE_MODULE = "players.PlayerDB"
|
#AUTH_PROFILE_MODULE = "players.PlayerDB"
|
||||||
# Use a custom test runner that just tests Evennia-specific apps.
|
# Use a custom test runner that just tests Evennia-specific apps.
|
||||||
TEST_RUNNER = 'src.server.testing_suite.EvenniaTestSuiteRunner'
|
TEST_RUNNER = 'src.server.tests.EvenniaTestSuiteRunner'
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
# Django extensions
|
# Django extensions
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue