Ticket #12991: unittest2_docs_patch.diff
File unittest2_docs_patch.diff, 3.0 KB (added by , 14 years ago) |
---|
-
docs/internals/contributing.txt
825 825 We appreciate any and all contributions to the test suite! 826 826 827 827 The 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. 828 Django 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 831 of how to write new tests. 831 832 832 833 Running the unit tests 833 834 ---------------------- -
docs/topics/testing.txt
52 52 return a_list[idx] 53 53 54 54 * **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:: 56 56 57 import unittest57 from django.utils import unittest 58 58 59 59 class MyFuncTestCase(unittest.TestCase): 60 60 def testBasic(self): … … 157 157 This module uses a different way of defining tests, taking a class-based 158 158 approach. 159 159 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 160 162 As with doctests, for a given Django application, the test runner looks for 161 163 unit tests in two places: 162 164 … … 170 172 This example ``unittest.TestCase`` subclass is equivalent to the example given 171 173 in the doctest section above:: 172 174 173 import unittest175 from django.utils import unittest 174 176 from myapp.models import Animal 175 177 176 178 class AnimalTestCase(unittest.TestCase): … … 233 235 routines, which give you a high level of control over the environment 234 236 in which your test cases are run. 235 237 238 * If you are writing tests for Django itself, you should use ``unittest``. 239 236 240 Again, remember that you can use both systems side-by-side (even in the same 237 241 app). In the end, most projects will eventually end up using both. Each shines 238 242 in different circumstances. … … 913 917 914 918 The following is a simple unit test using the test client:: 915 919 916 import unittest920 from django.utils import unittest 917 921 from django.test.client import Client 918 922 919 923 class SimpleTest(unittest.TestCase): … … 1010 1014 1011 1015 This means, instead of instantiating a ``Client`` in each test:: 1012 1016 1013 import unittest1017 from django.utils import unittest 1014 1018 from django.test.client import Client 1015 1019 1016 1020 class SimpleTest(unittest.TestCase):