Skip to content

Commit e0bd235

Browse files
committed
[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
1 parent 9d69c8f commit e0bd235

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

django/test/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44

55
from django.test.client import Client
66
from django.test.testcases import TestCase, TransactionTestCase
7+
from django.test.utils import skipIfDBEngine

django/test/utils.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
from django.conf import settings
33
from django.core import mail
44
from django.core.mail.backends import locmem
5+
from django.db import DEFAULT_DB_ALIAS
56
from django.test import signals
67
from django.template import Template
78
from django.utils.translation import deactivate
9+
from django.utils.unittest import skipIf
810

911
class ContextList(list):
1012
"""A wrapper that provides direct key access to context items contained
@@ -77,3 +79,14 @@ def get_runner(settings):
7779
test_module = __import__(test_module_name, {}, {}, test_path[-1])
7880
test_runner = getattr(test_module, test_path[-1])
7981
return test_runner
82+
83+
def skipIfDBEngine(engine, reason=None):
84+
"""
85+
Decorator to skip tests on a given database engine.
86+
87+
Note that you can pass a single engine or an iterable here
88+
"""
89+
if not reason:
90+
reason = "not supported on this database"
91+
return skipIf(settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'] in engine,
92+
reason)

0 commit comments

Comments
 (0)