Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Refs #12991 -- Added extra docs for the unittest2 changes made in r14…

…139.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14140 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 5e319f5194656849f1660c5d6ff2df695ed13c75 1 parent 121d2e3
Russell Keith-Magee authored October 11, 2010
6  docs/internals/deprecation.txt
@@ -108,6 +108,12 @@ their deprecation, as per the :ref:`Django deprecation policy
108 108
           :attr:`~django.test.client.Response.templates` attribute should be
109 109
           used instead.
110 110
 
  111
+        * The features of the :class:`django.test.simple.DjangoTestRunner`
  112
+          (including fail-fast and Ctrl-C test termination) can now be provided
  113
+          by the unittest-native :class:`TextTestRunner`. The
  114
+          :class:`~django.test.simple.DjangoTestRunner` will be removed in
  115
+          favor of using the unittest-native class.
  116
+
111 117
     * 2.0
112 118
         * ``django.views.defaults.shortcut()``. This function has been moved
113 119
           to ``django.contrib.contenttypes.views.shortcut()`` as part of the
55  docs/topics/testing.txt
@@ -1431,6 +1431,61 @@ manually, assign the empty list to ``mail.outbox``::
1431 1431
     # Empty the test outbox
1432 1432
     mail.outbox = []
1433 1433
 
  1434
+Skipping tests
  1435
+--------------
  1436
+
  1437
+.. versionadded:: 1.3
  1438
+
  1439
+The unittest library provides the ``@skipIf`` and ``@skipUnless``
  1440
+decorators to allow you to skip tests if you know ahead of time that
  1441
+those tests are going to fail under certain conditions.
  1442
+
  1443
+For example, if your test requires a particular optional library in
  1444
+order to succeed, you could decorate the test case with ``@skipIf``.
  1445
+Then, the test runner will report that the test wasn't executed and
  1446
+why, instead of failing the test or omitting the test altogether.
  1447
+
  1448
+To supplement these test skipping behaviors, Django provides two
  1449
+additional skip decorators. Instead of testing a generic boolean,
  1450
+these decorators check the capabilities of the database, and skip the
  1451
+test if the database doesn't support a specific named feature.
  1452
+
  1453
+The decorators use a string identifier to describe database features.
  1454
+This string corresponds to attributes of the database connection
  1455
+features class. See :class:`~django.db.backends.BaseDatabaseFeatures`
  1456
+class for a full list of database features that can be used as a basis
  1457
+for skipping tests.
  1458
+
  1459
+skipIfDBFeature
  1460
+~~~~~~~~~~~~~~~
  1461
+
  1462
+Skip the decorated test if the named database feature is supported.
  1463
+
  1464
+For example, the following test will not be executed if the database
  1465
+supports transactions (e.g., it would *not* run under PostgreSQL, but
  1466
+it would under MySQL with MyISAM tables)::
  1467
+
  1468
+    class MyTests(TestCase):
  1469
+        @skipIfDBFeature('supports_transactions')
  1470
+        def test_transaction_behavior(self):
  1471
+            # ... conditional test code
  1472
+
  1473
+skipUnlessDBFeature
  1474
+~~~~~~~~~~~~~~~~~~~
  1475
+
  1476
+Skip the decorated test if the named database feature is *not*
  1477
+supported.
  1478
+
  1479
+For example, the following test will not be executed if the database
  1480
+supports transactions (e.g., it would run under PostgreSQL, but *not*
  1481
+under MySQL with MyISAM tables)::
  1482
+
  1483
+    class MyTests(TestCase):
  1484
+        @skipUnlessDBFeature('supports_transactions')
  1485
+        def test_transaction_behavior(self):
  1486
+            # ... conditional test code
  1487
+
  1488
+
1434 1489
 Using different testing frameworks
1435 1490
 ==================================
1436 1491
 

0 notes on commit 5e319f5

Please sign in to comment.
Something went wrong with that request. Please try again.