Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[soc2010/test-refactor] Added skipIfDBEngine() decorator to django.test

  • Loading branch information...
commit e0bd235ffa78e74cdeccac5dabedd66487fd124f 1 parent 9d69c8f
@PaulMcMillan PaulMcMillan authored
Showing with 14 additions and 0 deletions.
  1. +1 −0  django/test/__init__.py
  2. +13 −0 django/test/utils.py
View
1  django/test/__init__.py
@@ -4,3 +4,4 @@
from django.test.client import Client
from django.test.testcases import TestCase, TransactionTestCase
+from django.test.utils import skipIfDBEngine
View
13 django/test/utils.py
@@ -2,9 +2,11 @@
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)
Please sign in to comment.
Something went wrong with that request. Please try again.