Author: PaulM
Date: 2010-07-02 14:06:53 -0500 (Fri, 02 Jul 2010)
New Revision: 13416

Modified:
   django/branches/soc2010/test-refactor/django/test/__init__.py
   django/branches/soc2010/test-refactor/django/test/utils.py
Log:
[soc2010/test-refactor] Added skipIfDBEngine() decorator to django.test


Modified: django/branches/soc2010/test-refactor/django/test/__init__.py
===================================================================
--- django/branches/soc2010/test-refactor/django/test/__init__.py       
2010-07-02 18:06:24 UTC (rev 13415)
+++ django/branches/soc2010/test-refactor/django/test/__init__.py       
2010-07-02 19:06:53 UTC (rev 13416)
@@ -4,3 +4,4 @@
 
 from django.test.client import Client
 from django.test.testcases import TestCase, TransactionTestCase
+from django.test.utils import skipIfDBEngine

Modified: django/branches/soc2010/test-refactor/django/test/utils.py
===================================================================
--- django/branches/soc2010/test-refactor/django/test/utils.py  2010-07-02 
18:06:24 UTC (rev 13415)
+++ django/branches/soc2010/test-refactor/django/test/utils.py  2010-07-02 
19:06:53 UTC (rev 13416)
@@ -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 @@
     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)

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to