Skip to content

Commit 3a6128b

Browse files
committed
docs: point to stable versions, improve references in a few places
1 parent 39ad360 commit 3a6128b

File tree

8 files changed

+54
-66
lines changed

8 files changed

+54
-66
lines changed

docs/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@
4040

4141
intersphinx_mapping = {
4242
'python': ('https://docs.python.org/3', None),
43-
'django': ('https://docs.djangoproject.com/en/dev/',
44-
'https://docs.djangoproject.com/en/dev/_objects/'),
45-
'pytest': ('https://docs.pytest.org/en/latest/', None),
43+
'django': ('https://docs.djangoproject.com/en/stable/',
44+
'https://docs.djangoproject.com/en/stable/_objects/'),
45+
'pytest': ('https://docs.pytest.org/en/stable/', None),
4646
}
4747

4848

docs/configuring_django.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ the tests.
99
The environment variable ``DJANGO_SETTINGS_MODULE``
1010
---------------------------------------------------
1111

12-
Running the tests with DJANGO_SETTINGS_MODULE defined will find the
12+
Running the tests with ``DJANGO_SETTINGS_MODULE`` defined will find the
1313
Django settings the same way Django does by default.
1414

1515
Example::

docs/database.rst

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ what code uses the database and catches any mistakes.
1212
Enabling database access in tests
1313
---------------------------------
1414

15-
You can use `pytest marks <https://pytest.org/en/latest/mark.html>`_ to
16-
tell ``pytest-django`` your test needs database access::
15+
You can use :ref:`pytest marks <pytest:mark>` to tell ``pytest-django`` your
16+
test needs database access::
1717

1818
import pytest
1919

@@ -24,10 +24,8 @@ tell ``pytest-django`` your test needs database access::
2424

2525
It is also possible to mark all tests in a class or module at once.
2626
This demonstrates all the ways of marking, even though they overlap.
27-
Just one of these marks would have been sufficient. See the `pytest
28-
documentation
29-
<https://pytest.org/en/latest/example/markers.html#marking-whole-classes-or-modules>`_
30-
for detail::
27+
Just one of these marks would have been sufficient. See the :ref:`pytest
28+
documentation <pytest:scoped-marking>` for detail::
3129

3230
import pytest
3331

@@ -45,20 +43,18 @@ By default ``pytest-django`` will set up the Django databases the
4543
first time a test needs them. Once setup the database is cached for
4644
used for all subsequent tests and rolls back transactions to isolate
4745
tests from each other. This is the same way the standard Django
48-
`TestCase
49-
<https://docs.djangoproject.com/en/1.9/topics/testing/tools/#testcase>`_
50-
uses the database. However ``pytest-django`` also caters for
51-
transaction test cases and allows you to keep the test databases
52-
configured across different test runs.
46+
:class:`~django.test.TestCase` uses the database. However
47+
``pytest-django`` also caters for transaction test cases and allows
48+
you to keep the test databases configured across different test runs.
5349

5450

5551
Testing transactions
5652
--------------------
5753

58-
Django itself has the ``TransactionTestCase`` which allows you to test
59-
transactions and will flush the database between tests to isolate
60-
them. The downside of this is that these tests are much slower to
61-
set up due to the required flushing of the database.
54+
Django itself has the :class:`~django.test.TransactionTestCase` which
55+
allows you to test transactions and will flush the database between
56+
tests to isolate them. The downside of this is that these tests are
57+
much slower to set up due to the required flushing of the database.
6258
``pytest-django`` also supports this style of tests, which you can
6359
select using an argument to the ``django_db`` mark::
6460

@@ -184,8 +180,9 @@ django_db_modify_db_settings
184180

185181
.. fixture:: django_db_modify_db_settings
186182

187-
This fixture allows modifying `django.conf.settings.DATABASES` just before the
188-
databases are configured.
183+
This fixture allows modifying
184+
`django.conf.settings.DATABASES <https://docs.djangoproject.com/en/stable/ref/settings/#databases>`_
185+
just before the databases are configured.
189186

190187
If you need to customize the location of your test database, this is the
191188
fixture you want to override.

docs/faq.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ for more information.
1616
How can I make sure that all my tests run with a specific locale?
1717
-----------------------------------------------------------------
1818

19-
Create a `pytest fixture <https://pytest.org/en/latest/fixture.html>`_ that is
20-
automatically run before each test case. To run all tests with the english
21-
locale, put the following code in your project's `conftest.py`_ file:
19+
Create a :ref:`pytest fixture <pytest:fixtures>` that is
20+
automatically run before each test case. To run all tests with the English
21+
locale, put the following code in your project's
22+
:ref:`conftest.py <pytest:plugins>` file:
2223

2324
.. code-block:: python
2425
@@ -28,8 +29,6 @@ locale, put the following code in your project's `conftest.py`_ file:
2829
def set_default_language():
2930
activate('en')
3031
31-
.. _conftest.py: http://docs.pytest.org/en/latest/plugins.html
32-
3332
.. _faq-tests-not-being-picked-up:
3433

3534
My tests are not being found. Why?
@@ -55,7 +54,7 @@ When debugging test collection problems, the ``--collectonly`` flag and
5554
``-rs`` (report skipped tests) can be helpful.
5655

5756
.. _related pytest docs:
58-
http://docs.pytest.org/en/latest/example/pythoncollection.html#changing-naming-conventions
57+
http://docs.pytest.org/en/stable/example/pythoncollection.html#changing-naming-conventions
5958

6059
Does pytest-django work with the pytest-xdist plugin?
6160
-----------------------------------------------------

docs/helpers.rst

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ All of Django's :py:class:`~django:django.test.TestCase`
1616
Markers
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
3230
will ensure the database is set up correctly for the test. Each test
3331
will run in its own transaction which will be rolled back at the end
3432
of the test. This behavior is the same as Django's standard
35-
`django.test.TestCase`_ class.
33+
:class:`~django.test.TestCase` class.
3634

3735
In order for a test to have access to the database it must either
3836
be 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

121115
pytest-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

133125
Example
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

152142
Example
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

183174
Example
184175
"""""""
@@ -208,7 +199,8 @@ Using the `admin_user` fixture will cause the test to automatically be marked fo
208199
~~~~~~~~~~~~~~~~~~~~~
209200

210201
A 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
212204
in the containing Django project.
213205

214206
Example
@@ -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
228221
is 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

265258
This fixture runs a live Django server in a background thread. The
266259
server'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
268261
also 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.
313306
If the assertion failed, the executed queries can be shown by using
314307
the 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

319312
Example usage::
320313

docs/index.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,13 @@ Why would I use this instead of Django's manage.py test command?
3939
Running the test suite with pytest offers some features that are not present in Django's standard test mechanism:
4040

4141
* Less boilerplate: no need to import unittest, create a subclass with methods. Just write tests as regular functions.
42-
* `Manage test dependencies with fixtures`_.
42+
* :ref:`Manage test dependencies with fixtures <pytest:fixtures>`.
4343
* Run tests in multiple processes for increased speed.
4444
* There are a lot of other nice plugins available for pytest.
4545
* Easy switching: Existing unittest-style tests will still work without any modifications.
4646

4747
See the `pytest documentation`_ for more information on pytest.
4848

49-
.. _Manage test dependencies with fixtures: http://docs.pytest.org/en/latest/fixture.html
5049
.. _pytest documentation: http://docs.pytest.org/
5150

5251
Bugs? Feature Suggestions?

docs/tutorial.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Talks, articles and blog posts
2121
John Costa
2222
<https://www.johnmcostaiii.net/post/2013-04-21-django-projects-to-django-apps-converting-the-unit-tests/>`_.
2323

24-
For general information and tutorials on pytest, see the `pytest tutorial page <https://pytest.org/en/latest/getting-started.html>`_.
24+
For general information and tutorials on pytest, see the `pytest tutorial page <https://pytest.org/en/stable/getting-started.html>`_.
2525

2626

2727
Step 1: Installation

docs/usage.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ the command line::
2020
pytest test_something.py a_directory
2121

2222
See the `pytest documentation on Usage and invocations
23-
<https://pytest.org/en/latest/usage.html>`_ for more help on available parameters.
23+
<https://pytest.org/en/stable/usage.html>`_ for more help on available parameters.
2424

2525
Additional command line options
2626
-------------------------------
@@ -51,6 +51,6 @@ is set to "foo", the test database with xdist will be "test_foo_gw0",
5151
"test_foo_gw1" etc.
5252

5353
See the full documentation on `pytest-xdist
54-
<https://pytest.org/en/latest/xdist.html>`_ for more information. Among other
55-
features, pytest-xdist can distribute/coordinate test execution on remote
56-
machines.
54+
<https://github.com/pytest-dev/pytest-xdist/blob/master/README.rst>`_ for more
55+
information. Among other features, pytest-xdist can distribute/coordinate test
56+
execution on remote machines.

0 commit comments

Comments
 (0)