Commits

Pa...@bcc190cf-cafb-0310-a4f2-bffc1f526a37  committed dc10628

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

  • Participants
  • Parent commits c82bd09
  • Branches soc2010/test-refactor

Comments (0)

Files changed (2)

File django/test/__init__.py

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

File django/test/utils.py

 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
     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)