summaryrefslogtreecommitdiff
path: root/django/test/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/test/utils.py')
-rw-r--r--django/test/utils.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/django/test/utils.py b/django/test/utils.py
index d34dd33d15..8430ef8f10 100644
--- a/django/test/utils.py
+++ b/django/test/utils.py
@@ -5,6 +5,7 @@ from django.core import mail
from django.test import signals
from django.template import Template
from django.utils.translation import deactivate
+import inspect
class ContextList(list):
"""A wrapper that provides direct key access to context items contained
@@ -80,8 +81,18 @@ def teardown_test_environment():
del mail.outbox
-def get_runner(settings):
- test_path = settings.TEST_RUNNER.split('.')
+def get_runner(settings, coverage = False, reports = False):
+ """
+ Based on the settings and parameters, returns the appropriate test
+ runner class.
+ """
+ if(coverage):
+ if(reports):
+ test_path = 'django.test.test_coverage.ReportingCoverageRunner'.split('.')
+ else:
+ test_path = settings.COVERAGE_TEST_RUNNER.split('.')
+ else:
+ test_path = settings.TEST_RUNNER.split('.')
# Allow for Python 2.5 relative paths
if len(test_path) > 1:
test_module_name = '.'.join(test_path[:-1])
@@ -90,3 +101,9 @@ def get_runner(settings):
test_module = __import__(test_module_name, {}, {}, test_path[-1])
test_runner = getattr(test_module, test_path[-1])
return test_runner
+
+def calling_func_name():
+ """
+ Inspect's on the stack to determine the calling functions name.
+ """
+ return inspect.stack()[1][3] \ No newline at end of file