summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul McMillan <Paul@McMillan.ws>2010-07-02 19:06:53 +0000
committerPaul McMillan <Paul@McMillan.ws>2010-07-02 19:06:53 +0000
commite0bd235ffa78e74cdeccac5dabedd66487fd124f (patch)
tree0bb48c80a0456563ffd140b0ae5ff14adc58267a
parent9d69c8f01d84186c5381a896afafb3d789afe9cb (diff)
[soc2010/test-refactor] Added skipIfDBEngine() decorator to django.test
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/test-refactor@13416 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/test/__init__.py1
-rw-r--r--django/test/utils.py13
2 files changed, 14 insertions, 0 deletions
diff --git a/django/test/__init__.py b/django/test/__init__.py
index 957b293e12..57f6014550 100644
--- a/django/test/__init__.py
+++ b/django/test/__init__.py
@@ -4,3 +4,4 @@ Django Unit Test and Doctest framework.
from django.test.client import Client
from django.test.testcases import TestCase, TransactionTestCase
+from django.test.utils import skipIfDBEngine
diff --git a/django/test/utils.py b/django/test/utils.py
index b6ab39901b..453ee3bf94 100644
--- a/django/test/utils.py
+++ b/django/test/utils.py
@@ -2,9 +2,11 @@ import sys, time, os
from django.conf import settings
from django.core import mail
from django.core.mail.backends import locmem
+from django.db import DEFAULT_DB_ALIAS
from django.test import signals
from django.template import Template
from django.utils.translation import deactivate
+from django.utils.unittest import skipIf
class ContextList(list):
"""A wrapper that provides direct key access to context items contained
@@ -77,3 +79,14 @@ 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 skipIfDBEngine(engine, reason=None):
+ """
+ Decorator to skip tests on a given database engine.
+
+ Note that you can pass a single engine or an iterable here
+ """
+ if not reason:
+ reason = "not supported on this database"
+ return skipIf(settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'] in engine,
+ reason)