Skip to content
This repository
Newer
Older
100644 230 lines (161 sloc) 8.107 kb
403b1fea »
2012-01-19 Pull a bunch of functionality out of test-utils. Bump version to 1.0.
1 ===========
2 django-nose
3 ===========
bdca5730 »
2009-10-01 Adding a rst version of the README
4
403b1fea »
2012-01-19 Pull a bunch of functionality out of test-utils. Bump version to 1.0.
5 Features
6 --------
bdca5730 »
2009-10-01 Adding a rst version of the README
7
4463e746 »
2012-03-28 Note some nice things about being able to use nose.
8 * All the goodness of `nose`_ in your Django tests, like...
9 * Testing just your apps by default, not all the standard ones that happen to
10 be in ``INSTALLED_APPS``
11 * Running the tests in one or more specific modules (or apps, or classes, or
12 running a specific test)
13 * Taking advantage of all the useful `nose plugins`_
5443b56f »
2012-03-13 Add a few more trove classifiers. Include changelog in distro.
14 * Fixture bundling, an optional feature which speeds up your fixture-based
403b1fea »
2012-01-19 Pull a bunch of functionality out of test-utils. Bump version to 1.0.
15 tests by a factor of 4
5443b56f »
2012-03-13 Add a few more trove classifiers. Include changelog in distro.
16 * Reuse of previously created test DBs, cutting 10 seconds off startup time
17 * Support for various databases. Tested with MySQL, PostgreSQL, and SQLite.
18 Others should work as well.
70de9dd1 »
2010-04-04 django < 1.2 compatibility
19
116971ab »
2012-01-19 Rename RunnyNose→BasicNoseRunner, and move settings_test.py support t…
20 .. _nose: http://somethingaboutorange.com/mrl/projects/nose/
4463e746 »
2012-03-28 Note some nice things about being able to use nose.
21 .. _nose plugins: http://nose-plugins.jottit.com/
70de9dd1 »
2010-04-04 django < 1.2 compatibility
22
23
bdca5730 »
2009-10-01 Adding a rst version of the README
24 Installation
25 ------------
26
403b1fea »
2012-01-19 Pull a bunch of functionality out of test-utils. Bump version to 1.0.
27 You can get django-nose from PyPI with... ::
bdca5730 »
2009-10-01 Adding a rst version of the README
28
29 pip install django-nose
30
403b1fea »
2012-01-19 Pull a bunch of functionality out of test-utils. Bump version to 1.0.
31 The development version can be installed with... ::
bdca5730 »
2009-10-01 Adding a rst version of the README
32
33 pip install -e git://github.com/jbalogh/django-nose.git#egg=django-nose
34
35 Since django-nose extends Django's built-in test command, you should add it to
403b1fea »
2012-01-19 Pull a bunch of functionality out of test-utils. Bump version to 1.0.
36 your ``INSTALLED_APPS`` in ``settings.py``::
bdca5730 »
2009-10-01 Adding a rst version of the README
37
38 INSTALLED_APPS = (
39 ...
40 'django_nose',
41 ...
42 )
43
403b1fea »
2012-01-19 Pull a bunch of functionality out of test-utils. Bump version to 1.0.
44 Then set ``TEST_RUNNER`` in ``settings.py``::
bdca5730 »
2009-10-01 Adding a rst version of the README
45
1dddd371 »
2010-01-25 updating the docs for 1.2 changes
46 TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
1a35ed9f »
2009-11-23 pass arguments from the gis tester to run_tests, style nits
47
bdca5730 »
2009-10-01 Adding a rst version of the README
48
403b1fea »
2012-01-19 Pull a bunch of functionality out of test-utils. Bump version to 1.0.
49 Use
50 ---
bdca5730 »
2009-10-01 Adding a rst version of the README
51
403b1fea »
2012-01-19 Pull a bunch of functionality out of test-utils. Bump version to 1.0.
52 The day-to-day use of django-nose is mostly transparent; just run ``./manage.py
43687f3f »
2012-03-12 Rewrite FORCE_DB docs to REUSE_DB.
53 test`` as usual.
116971ab »
2012-01-19 Rename RunnyNose→BasicNoseRunner, and move settings_test.py support t…
54
43687f3f »
2012-03-12 Rewrite FORCE_DB docs to REUSE_DB.
55 See ``./manage.py help test`` for all the options nose provides, and look to
56 the `nose docs`_ for more help with nose.
116971ab »
2012-01-19 Rename RunnyNose→BasicNoseRunner, and move settings_test.py support t…
57
43687f3f »
2012-03-12 Rewrite FORCE_DB docs to REUSE_DB.
58 .. _nose docs: http://somethingaboutorange.com/mrl/projects/nose/
116971ab »
2012-01-19 Rename RunnyNose→BasicNoseRunner, and move settings_test.py support t…
59
60
43687f3f »
2012-03-12 Rewrite FORCE_DB docs to REUSE_DB.
61 Enabling Database Reuse
62 -----------------------
116971ab »
2012-01-19 Rename RunnyNose→BasicNoseRunner, and move settings_test.py support t…
63
43687f3f »
2012-03-12 Rewrite FORCE_DB docs to REUSE_DB.
64 You can save several seconds at the beginning and end of your test suite by
65 reusing the test database from the last run. To do this, set the environment
66 variable ``REUSE_DB`` to 1::
83c7867c »
2011-09-06 Allow a test class to opt out of fixture bundling. Closes #10.
67
43687f3f »
2012-03-12 Rewrite FORCE_DB docs to REUSE_DB.
68 REUSE_DB=1 ./manage.py test
69
70 The one new wrinkle is that, whenever your DB schema changes, you should leave
71 the flag off the next time you run tests. This will cue the test runner to
72 reinitialize the test database.
403b1fea »
2012-01-19 Pull a bunch of functionality out of test-utils. Bump version to 1.0.
73
74
116971ab »
2012-01-19 Rename RunnyNose→BasicNoseRunner, and move settings_test.py support t…
75 Enabling Fast Fixtures
76 ----------------------
83c7867c »
2011-09-06 Allow a test class to opt out of fixture bundling. Closes #10.
77
116971ab »
2012-01-19 Rename RunnyNose→BasicNoseRunner, and move settings_test.py support t…
78 django-nose includes a nose plugin which drastically speeds up your tests by
79 eliminating redundant setup of Django test fixtures. To use it...
403b1fea »
2012-01-19 Pull a bunch of functionality out of test-utils. Bump version to 1.0.
80
81 1. Subclass ``django_nose.FastFixtureTestCase`` instead of
82 ``django.test.TestCase``. (I like to import it ``as TestCase`` in my
83 project's ``tests/__init__.py`` and then import it from there into my actual
293d559f »
2012-03-12 Polish up readme and changelog for 1.0 release.
84 tests. Then it's easy to sub the base class in and out.)
4463e746 »
2012-03-28 Note some nice things about being able to use nose.
85 2. Activate the plugin by passing the ``--with-fixture-bundling`` option to
86 ``./manage.py test``.
83c7867c »
2011-09-06 Allow a test class to opt out of fixture bundling. Closes #10.
87
88 How Fixture Bundling Works
89 ~~~~~~~~~~~~~~~~~~~~~~~~~~
90
91 The fixture bundler reorders your test classes so that ones with identical sets
92 of fixtures run adjacently. It then advises the first of each series to load
93 the fixtures once for all of them (and the remaining ones not to bother). It
94 also advises the last to tear them down. Depending on the size and repetition
95 of your fixtures, you can expect a 25% to 50% speed increase.
96
97 Incidentally, the author prefers to avoid Django fixtures, as they encourage
98 irrelevant coupling between tests and make tests harder to comprehend and
99 modify. For future tests, it is better to use the "model maker" pattern,
100 creating DB objects programmatically. This way, tests avoid setup they don't
101 need, and there is a clearer tie between a test and the exact state it
102 requires. The fixture bundler is intended to make existing tests, which have
103 already committed to fixtures, more tolerable.
104
105 Troubleshooting
106 ~~~~~~~~~~~~~~~
107
108 If using ``--with-fixture-bundling`` causes test failures, it likely indicates
109 an order dependency between some of your tests. Here are the most frequent
110 sources of state leakage we have encountered:
111
112 * Locale activation, which is maintained in a threadlocal variable. Be sure to
113 reset your locale selection between tests.
403b1fea »
2012-01-19 Pull a bunch of functionality out of test-utils. Bump version to 1.0.
114 * memcached contents. Be sure to flush between tests. Many test superclasses do
115 this automatically.
116
117 It's also possible that you have ``post_save`` signal handlers which create
116971ab »
2012-01-19 Rename RunnyNose→BasicNoseRunner, and move settings_test.py support t…
118 additional database rows while loading the fixtures. ``FastFixtureTestCase``
119 isn't yet smart enough to notice this and clean up after it, so you'll have to
120 go back to plain old ``TestCase`` for now.
83c7867c »
2011-09-06 Allow a test class to opt out of fixture bundling. Closes #10.
121
122 Exempting A Class From Bundling
123 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
124
125 In some unusual cases, it is desirable to exempt a test class from fixture
126 bundling, forcing it to set up and tear down its fixtures at the class
127 boundaries. For example, we might have a ``TestCase`` subclass which sets up
128 some state outside the DB in ``setUpClass`` and tears it down in
129 ``tearDownClass``, and it might not be possible to adapt those routines to heed
130 the advice of the fixture bundler. In such a case, simply set the
131 ``exempt_from_fixture_bundling`` attribute of the test class to ``True``.
bdca5730 »
2009-10-01 Adding a rst version of the README
132
403b1fea »
2012-01-19 Pull a bunch of functionality out of test-utils. Bump version to 1.0.
133
134 Using With South
135 ----------------
136
137 `South`_ installs its own test command that turns off migrations during
e6423ac7 »
2012-01-20 Tweak readme.
138 testing. Make sure that django-nose comes *after* ``south`` in
403b1fea »
2012-01-19 Pull a bunch of functionality out of test-utils. Bump version to 1.0.
139 ``INSTALLED_APPS`` so that django_nose's test command is used.
140
141 .. _South: http://south.aeracode.org/
142
9c2d2e03 »
2010-08-05 Custom nose plugins can now be specified in settings.py.
143
144 Always Passing The Same Options
403b1fea »
2012-01-19 Pull a bunch of functionality out of test-utils. Bump version to 1.0.
145 -------------------------------
9c2d2e03 »
2010-08-05 Custom nose plugins can now be specified in settings.py.
146
049a82c4 »
2010-08-07 The mentions of nose configuration and custom nose plugins now link t…
147 To always set the same command line options you can use a `nose.cfg or
148 setup.cfg`_ (as usual) or you can specify them in settings.py like this::
149
9c2d2e03 »
2010-08-05 Custom nose plugins can now be specified in settings.py.
150 NOSE_ARGS = ['--failed', '--stop']
151
403b1fea »
2012-01-19 Pull a bunch of functionality out of test-utils. Bump version to 1.0.
152 .. _nose.cfg or setup.cfg: http://somethingaboutorange.com/mrl/projects/nose/0.11.2/usage.html#configuration
153
154
155 Custom Plugins
156 --------------
9c2d2e03 »
2010-08-05 Custom nose plugins can now be specified in settings.py.
157
049a82c4 »
2010-08-07 The mentions of nose configuration and custom nose plugins now link t…
158 If you need to `make custom plugins`_, you can define each plugin class
159 somewhere within your app and load them from settings.py like this::
9c2d2e03 »
2010-08-05 Custom nose plugins can now be specified in settings.py.
160
161 NOSE_PLUGINS = [
162 'yourapp.tests.plugins.SystematicDysfunctioner',
163 # ...
164 ]
165
403b1fea »
2012-01-19 Pull a bunch of functionality out of test-utils. Bump version to 1.0.
166 Just like middleware or anything else, each string must be a dot-separated,
167 importable path to an actual class. Each plugin class will be instantiated and
9c2d2e03 »
2010-08-05 Custom nose plugins can now be specified in settings.py.
168 added to the Nose test runner.
169
403b1fea »
2012-01-19 Pull a bunch of functionality out of test-utils. Bump version to 1.0.
170 .. _make custom plugins: http://somethingaboutorange.com/mrl/projects/nose/0.11.2/plugins.html#writing-plugins
bdca5730 »
2009-10-01 Adding a rst version of the README
171
172
403b1fea »
2012-01-19 Pull a bunch of functionality out of test-utils. Bump version to 1.0.
173 Older Versions of Django
174 ------------------------
175
176 Upgrading from Django < 1.2
177 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
178
e6423ac7 »
2012-01-20 Tweak readme.
179 Django 1.2 switches to a `class-based test runner`_. To use django-nose
403b1fea »
2012-01-19 Pull a bunch of functionality out of test-utils. Bump version to 1.0.
180 with Django 1.2, change your ``TEST_RUNNER`` from ``django_nose.run_tests`` to
181 ``django_nose.NoseTestSuiteRunner``.
b130825c »
2011-02-03 mention django 1.1 support
182
293d559f »
2012-03-12 Polish up readme and changelog for 1.0 release.
183 ``django_nose.run_tests`` will continue to work in Django 1.2 but will raise a
184 warning. In Django 1.3, it will stop working.
403b1fea »
2012-01-19 Pull a bunch of functionality out of test-utils. Bump version to 1.0.
185
186 If you were using ``django_nose.run_gis_tests``, you should also switch to
187 ``django_nose.NoseTestSuiteRunner`` and use one of the `spatial backends`_ in
188 your ``DATABASES`` settings.
189
190 .. _class-based test runner: http://docs.djangoproject.com/en/dev/releases/1.2/#function-based-test-runners
191 .. _spatial backends: http://docs.djangoproject.com/en/dev/ref/contrib/gis/db-api/#id1
b130825c »
2011-02-03 mention django 1.1 support
192
403b1fea »
2012-01-19 Pull a bunch of functionality out of test-utils. Bump version to 1.0.
193 Django 1.1
194 ~~~~~~~~~~
b130825c »
2011-02-03 mention django 1.1 support
195
196 If you want to use django-nose with Django 1.1, use
197 https://github.com/jbalogh/django-nose/tree/django-1.1 or
198 http://pypi.python.org/pypi/django-nose/0.0.3.
293d559f »
2012-03-12 Polish up readme and changelog for 1.0 release.
199
274eb8b6 »
2012-03-28 Note that we don't support Django 1.0. Closes #64.
200 Django 1.0
201 ~~~~~~~~~~
202
203 django-nose does not support Django 1.0.
204
293d559f »
2012-03-12 Polish up readme and changelog for 1.0 release.
205
206 Recent Version History
207 ----------------------
208
7df10205 »
2012-03-13 Merge in Roger's SQLAlchemy connection pooling fix. Bump version to 1…
209 1.0.1
210 * Fixed an error that would surface when using SQLAlchemy with connection
211 pooling. (Roger Hu)
212
293d559f »
2012-03-12 Polish up readme and changelog for 1.0 release.
213 1.0 (2012-03-12)
214 * New fixture-bundling plugin for avoiding needless fixture setup (Erik Rose)
215 * Moved FastFixtureTestCase in from test-utils, so now all the
216 fixture-bundling stuff is in one library. (Erik Rose)
217 * Added the REUSE_DB setting for faster startup and shutdown. (Erik Rose)
218 * Fixed a crash when printing options with certain verbosities. (Daniel Abel)
219 * Broke hard dependency on MySQL. Support PostgreSQL. (Roger Hu)
220 * Support SQLite, both memory- and disk-based. (Roger Hu and Erik Rose)
30188c1a »
2012-03-13 Nail down version numbers for dependencies.
221 * Nail down versions of the package requirements. (Daniel Mizyrycki)
293d559f »
2012-03-12 Polish up readme and changelog for 1.0 release.
222
223 0.1.3 (2010-04-15)
224 * Even better coverage support (rozza)
225 * README fixes (carljm and ionelmc)
226 * optparse OptionGroups are handled better (outofculture)
227 * nose plugins are loaded before listing options
5443b56f »
2012-03-13 Add a few more trove classifiers. Include changelog in distro.
228
229 See more in changelog.txt.
Something went wrong with that request. Please try again.