Ticket #12991: unittest2_docs_patch.diff

File unittest2_docs_patch.diff, 3.0 KB (added by Paul McMillan, 14 years ago)

Adds information about unittest changes to contributing and testing docs.

  • docs/internals/contributing.txt

     
    825825We appreciate any and all contributions to the test suite!
    826826
    827827The Django tests all use the testing infrastructure that ships with
    828 Django for testing applications. New tests should use the unittest
    829 framework. See :ref:`Testing Django applications <topics-testing>` for
    830 an explanation of how to write new tests.
     828Django for testing applications. New tests should use
     829``django.utils.unittest``, and should not include doctests. See
     830:ref:`Testing Django applications <topics-testing>` for an explanation
     831of how to write new tests.
    831832
    832833Running the unit tests
    833834----------------------
  • docs/topics/testing.txt

     
    5252              return a_list[idx]
    5353
    5454    * **Unit tests** -- tests that are expressed as methods on a Python class
    55       that subclasses ``unittest.TestCase``. For example::
     55      that subclasses ``django.utils.unittest.TestCase``. For example::
    5656
    57           import unittest
     57          from django.utils import unittest
    5858
    5959          class MyFuncTestCase(unittest.TestCase):
    6060              def testBasic(self):
     
    157157This module uses a different way of defining tests, taking a class-based
    158158approach.
    159159
     160.. versionchanged:: 1.3 Django bundles the Python 2.7 unittest library as ``django.utils.unittest``. You can still use the system ``unittest`` package, but the the bundled package includes more verbose error reporting and additional assertions for versions of Python below 2.7.
     161
    160162As with doctests, for a given Django application, the test runner looks for
    161163unit tests in two places:
    162164
     
    170172This example ``unittest.TestCase`` subclass is equivalent to the example given
    171173in the doctest section above::
    172174
    173     import unittest
     175    from django.utils import unittest
    174176    from myapp.models import Animal
    175177
    176178    class AnimalTestCase(unittest.TestCase):
     
    233235      routines, which give you a high level of control over the environment
    234236      in which your test cases are run.
    235237
     238    * If you are writing tests for Django itself, you should use ``unittest``.
     239
    236240Again, remember that you can use both systems side-by-side (even in the same
    237241app). In the end, most projects will eventually end up using both. Each shines
    238242in different circumstances.
     
    913917
    914918The following is a simple unit test using the test client::
    915919
    916     import unittest
     920    from django.utils import unittest
    917921    from django.test.client import Client
    918922
    919923    class SimpleTest(unittest.TestCase):
     
    10101014
    10111015This means, instead of instantiating a ``Client`` in each test::
    10121016
    1013     import unittest
     1017    from django.utils import unittest
    10141018    from django.test.client import Client
    10151019
    10161020    class SimpleTest(unittest.TestCase):
Back to Top