@@ -16,11 +16,9 @@ All of Django's :py:class:`~django:django.test.TestCase`
1616Markers
1717-------
1818
19- ``pytest-django `` registers and uses markers. See the pytest documentation _
20- on what marks are and for notes on using _ them.
21-
22- .. _documentation : https://pytest.org/en/latest/mark.html
23- .. _using : https://pytest.org/en/latest/example/markers.html#marking-whole-classes-or-modules
19+ ``pytest-django `` registers and uses markers. See the pytest
20+ :ref: `documentation <pytest:mark >` on what marks are and for notes on
21+ :ref: `using <pytest:scoped-marking >` them.
2422
2523
2624``pytest.mark.django_db `` - request database access
@@ -32,7 +30,7 @@ This is used to mark a test function as requiring the database. It
3230will ensure the database is set up correctly for the test. Each test
3331will run in its own transaction which will be rolled back at the end
3432of the test. This behavior is the same as Django's standard
35- ` django.test.TestCase `_ class.
33+ :class: ` ~ django.test.TestCase ` class.
3634
3735In order for a test to have access to the database it must either
3836be marked using the ``django_db `` mark or request one of the ``db ``,
@@ -44,9 +42,8 @@ test will fail when trying to access the database.
4442 The ``transaction `` argument will allow the test to use real transactions.
4543 With ``transaction=False `` (the default when not specified), transaction
4644 operations are noops during the test. This is the same behavior that
47- `django.test.TestCase `_
48- uses. When ``transaction=True ``, the behavior will be the same as
49- `django.test.TransactionTestCase `_
45+ :class: `django.test.TestCase ` uses. When ``transaction=True ``, the behavior
46+ will be the same as :class: `django.test.TransactionTestCase `.
5047
5148
5249:type reset_sequences: bool
@@ -68,13 +65,10 @@ test will fail when trying to access the database.
6865
6966.. note :: Automatic usage with ``django.test.TestCase``.
7067
71- Test classes that subclass `django.test.TestCase `_ will have access to
68+ Test classes that subclass :class: `django.test.TestCase ` will have access to
7269 the database always to make them compatible with existing Django tests.
73- Test classes that subclass Python's ``unittest.TestCase `` need to have the
74- marker applied in order to access the database.
75-
76- .. _django.test.TestCase : https://docs.djangoproject.com/en/dev/topics/testing/overview/#testcase
77- .. _django.test.TransactionTestCase : https://docs.djangoproject.com/en/dev/topics/testing/overview/#transactiontestcase
70+ Test classes that subclass Python's :class: `unittest.TestCase ` need to have
71+ the marker applied in order to access the database.
7872
7973
8074``pytest.mark.urls `` - override the urlconf
@@ -119,16 +113,14 @@ Fixtures
119113--------
120114
121115pytest-django provides some pytest fixtures to provide dependencies for tests.
122- More information on fixtures is available in the `pytest documentation
123- <https:// pytest.org/en/latest/fixture.html> `_ .
116+ More information on fixtures is available in the :ref: `pytest documentation
117+ <pytest:fixtures>` .
124118
125119
126120``rf `` - ``RequestFactory ``
127121~~~~~~~~~~~~~~~~~~~~~~~~~~~
128122
129- An instance of a `django.test.RequestFactory `_
130-
131- .. _django.test.RequestFactory : https://docs.djangoproject.com/en/dev/topics/testing/advanced/#django.test.RequestFactory
123+ An instance of a :class: `django.test.RequestFactory `.
132124
133125Example
134126"""""""
@@ -145,9 +137,7 @@ Example
145137``client `` - ``django.test.Client ``
146138~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
147139
148- An instance of a `django.test.Client `_
149-
150- .. _django.test.Client : https://docs.djangoproject.com/en/dev/topics/testing/tools/#the-test-client
140+ An instance of a :class: `django.test.Client `.
151141
152142Example
153143"""""""
@@ -158,8 +148,9 @@ Example
158148 response = client.get('/')
159149 assert response.content == 'Foobar'
160150
161- To use `client ` as an authenticated standard user, call its `force_login() ` or
162- `login() ` method before accessing a URL:
151+ To use `client ` as an authenticated standard user, call its
152+ :meth: `force_login() <django.test.Client.force_login> ` or
153+ :meth: `login() <django.test.Client.login()> ` method before accessing a URL:
163154
164155::
165156
@@ -178,7 +169,7 @@ To use `client` as an authenticated standard user, call its `force_login()` or
178169``admin_client `` - ``django.test.Client `` logged in as admin
179170~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
180171
181- An instance of a `django.test.Client `_ , logged in as an admin user.
172+ An instance of a :class: `django.test.Client `, logged in as an admin user.
182173
183174Example
184175"""""""
@@ -208,7 +199,8 @@ Using the `admin_user` fixture will cause the test to automatically be marked fo
208199~~~~~~~~~~~~~~~~~~~~~
209200
210201A shortcut to the User model configured for use by the current Django project (aka the model referenced by
211- `settings.AUTH_USER_MODEL `). Use this fixture to make pluggable apps testable regardless what User model is configured
202+ `settings.AUTH_USER_MODEL <https://docs.djangoproject.com/en/stable/ref/settings/#auth-user-model >`_).
203+ Use this fixture to make pluggable apps testable regardless what User model is configured
212204in the containing Django project.
213205
214206Example
@@ -223,8 +215,9 @@ Example
223215``django_username_field ``
224216~~~~~~~~~~~~~~~~~~~~~~~~~
225217
226- This fixture extracts the field name used for the username on the user model, i.e. resolves to the current
227- ``settings.USERNAME_FIELD ``. Use this fixture to make pluggable apps testable regardless what the username field
218+ This fixture extracts the field name used for the username on the user model, i.e.
219+ resolves to the user model's :attr: `~django.contrib.auth.models.CustomUser.USERNAME_FIELD `.
220+ Use this fixture to make pluggable apps testable regardless what the username field
228221is configured to be in the containing Django project.
229222
230223``db ``
@@ -264,7 +257,7 @@ normally use the ``pytest.mark.django_db`` mark with ``transaction=True`` and ``
264257
265258This fixture runs a live Django server in a background thread. The
266259server's URL can be retrieved using the ``live_server.url `` attribute
267- or by requesting it's string value: ``unicode (live_server) ``. You can
260+ or by requesting it's string value: ``str (live_server) ``. You can
268261also directly concatenate a string to form a URL: ``live_server +
269262'/foo ``.
270263
@@ -313,8 +306,8 @@ This fixture allows to check for an expected number of DB queries.
313306If the assertion failed, the executed queries can be shown by using
314307the verbose command line option.
315308
316- It wraps `django.test.utils.CaptureQueriesContext ` and yields the wrapped
317- CaptureQueriesContext instance.
309+ It wraps `` django.test.utils.CaptureQueriesContext ` ` and yields the wrapped
310+ `` CaptureQueriesContext `` instance.
318311
319312Example usage::
320313
0 commit comments