Skip to content

Commit

Permalink
docs: some minor fixes & improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
bluetech committed Oct 26, 2023
1 parent c3382c4 commit 922dd1f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ v3.3.3 (2018-07-26)
Bug fixes
^^^^^^^^^

* Fixed registration of :py:func:`~pytest.mark.ignore_template_errors` marker,
* Fixed registration of :func:`~pytest.mark.ignore_template_errors` marker,
which is required with ``pytest --strict`` (#609).
* Fixed another regression with unittest (#624, #625).

Expand Down Expand Up @@ -458,7 +458,7 @@ Features

* Added new fixtures ``django_mail_dnsname`` and ``django_mail_patch_dns``,
used by ``mailoutbox`` to monkeypatch the ``DNS_NAME`` used in
:py:mod:`django.core.mail` to improve performance and
:mod:`django.core.mail` to improve performance and
reproducibility.

Bug fixes
Expand Down
4 changes: 2 additions & 2 deletions docs/configuring_django.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ but it can also be requested individually per-test.
Changing your app before Django gets set up
-------------------------------------------

pytest-django calls :py:func:`django.setup` automatically. If you want to do
pytest-django calls :func:`django.setup` automatically. If you want to do
anything before this, you have to create a pytest plugin and use
the :py:func:`~_pytest.hookspec.pytest_load_initial_conftests` hook, with
the :func:`~_pytest.hookspec.pytest_load_initial_conftests` hook, with
``tryfirst=True``, so that it gets run before the hook in pytest-django
itself::

Expand Down
6 changes: 3 additions & 3 deletions docs/database.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ Tests requiring multiple databases
``pytest-django`` has experimental support for multi-database configurations.
Currently ``pytest-django`` does not specifically support Django's
multi-database support, using the ``databases`` argument to the
:py:func:`django_db <pytest.mark.django_db>` mark::
:func:`django_db <pytest.mark.django_db>` mark::

@pytest.mark.django_db(databases=['default', 'other'])
def test_spam():
assert MyModel.objects.using('other').count() == 0

For details see :py:attr:`django.test.TransactionTestCase.databases` and
:py:attr:`django.test.TestCase.databases`.
For details see :attr:`django.test.TransactionTestCase.databases` and
:attr:`django.test.TestCase.databases`.


``--reuse-db`` - reuse the testing database between test runs
Expand Down
4 changes: 2 additions & 2 deletions docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ test runner like this:
help='Preserves the test DB between runs.'
)
def run_tests(self, test_labels):
def run_tests(self, test_labels, **kwargs):
"""Run pytest and return the exitcode.
It translates some of Django's test command option to pytest's.
Expand Down Expand Up @@ -126,7 +126,7 @@ Usage:
**Note**: the pytest-django command line options ``--ds`` and ``--dc`` are not
compatible with this approach, you need to use the standard Django methods of
setting the ``DJANGO_SETTINGS_MODULE``/``DJANGO_CONFIGURATION`` environmental
setting the ``DJANGO_SETTINGS_MODULE``/``DJANGO_CONFIGURATION`` environment
variables or the ``--settings`` command line option.

How can I give database access to all my tests without the `django_db` marker?
Expand Down
22 changes: 11 additions & 11 deletions docs/helpers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Django helpers
Assertions
----------

All of Django's :py:class:`~django:django.test.TestCase`
All of Django's :class:`~django:django.test.TestCase`
:ref:`django:assertions` are available in ``pytest_django.asserts``, e.g.

::
Expand All @@ -26,7 +26,7 @@ dynamically in a hook or fixture.
``pytest.mark.django_db`` - request database access
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. py:function:: pytest.mark.django_db([transaction=False, reset_sequences=False, databases=None])
.. decorator:: pytest.mark.django_db([transaction=False, reset_sequences=False, databases=None, serialized_rollback=False, available_apps=None])

This is used to mark a test function as requiring the database. It
will ensure the database is set up correctly for the test. Each test
Expand Down Expand Up @@ -54,10 +54,10 @@ dynamically in a hook or fixture.
values (e.g. primary keys) before running the test. Defaults to
``False``. Must be used together with ``transaction=True`` to have an
effect. Please be aware that not all databases support this feature.
For details see :py:attr:`django.test.TransactionTestCase.reset_sequences`.
For details see :attr:`django.test.TransactionTestCase.reset_sequences`.


:type databases: Union[Iterable[str], str, None]
:type databases: Iterable[str] | str | None
:param databases:
.. caution::

Expand All @@ -70,8 +70,8 @@ dynamically in a hook or fixture.
configuration will be set up and may be used by the test. Defaults to
only the ``default`` database. The special value ``"__all__"`` may be use
to specify all configured databases.
For details see :py:attr:`django.test.TransactionTestCase.databases` and
:py:attr:`django.test.TestCase.databases`.
For details see :attr:`django.test.TransactionTestCase.databases` and
:attr:`django.test.TestCase.databases`.

:type serialized_rollback: bool
:param serialized_rollback:
Expand All @@ -84,7 +84,7 @@ dynamically in a hook or fixture.

Note that this will slow down that test suite by approximately 3x.

:type available_apps: Union[List[str], None]
:type available_apps: Iterable[str] | None
:param available_apps:
.. caution::

Expand All @@ -97,7 +97,7 @@ dynamically in a hook or fixture.
model tables will be emptied after each test (this truncation may cascade
to unavailable apps models).

For details see :py:attr:`django.test.TransactionTestCase.available_apps`
For details see :attr:`django.test.TransactionTestCase.available_apps`


.. note::
Expand All @@ -122,7 +122,7 @@ dynamically in a hook or fixture.
``pytest.mark.urls`` - override the urlconf
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. py:function:: pytest.mark.urls(urls)
.. decorator:: pytest.mark.urls(urls)

Specify a different ``settings.ROOT_URLCONF`` module for the marked tests.

Expand All @@ -141,7 +141,7 @@ dynamically in a hook or fixture.
``pytest.mark.ignore_template_errors`` - ignore invalid template variables
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. py:function:: pytest.mark.ignore_template_errors
.. decorator:: pytest.mark.ignore_template_errors

Ignore errors when using the ``--fail-on-template-vars`` option, i.e.
do not cause tests to fail if your templates contain invalid variables.
Expand Down Expand Up @@ -540,7 +540,7 @@ Example


This uses the ``django_mail_patch_dns`` fixture, which patches
``DNS_NAME`` used by :py:mod:`django.core.mail` with the value from
``DNS_NAME`` used by :mod:`django.core.mail` with the value from
the ``django_mail_dnsname`` fixture, which defaults to
"fake-tests.example.com".

Expand Down

0 comments on commit 922dd1f

Please sign in to comment.