Skip to content

Commit 34582a4

Browse files
committed
undo
1 parent b51117c commit 34582a4

File tree

5 files changed

+136
-136
lines changed

5 files changed

+136
-136
lines changed

docs/faq.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ How can I use ``manage.py test`` with pytest-django?
7979
----------------------------------------------------
8080

8181
pytest-django is designed to work with the ``pytest`` command, but if you
82-
really need integration with ``manage.py test``, you can add this class path
82+
really need integration with ``manage.py test``, you can add this class path
8383
in your Django settings:
8484

8585
.. code-block:: python

docs/helpers.rst

Lines changed: 110 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -28,82 +28,82 @@ dynamically in a hook or fixture.
2828

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

31-
This is used to mark a test function as requiring the database. It
32-
will ensure the database is set up correctly for the test. Each test
33-
will run in its own transaction which will be rolled back at the end
34-
of the test. This behavior is the same as Django's standard
35-
:class:`~django.test.TestCase` class.
36-
37-
In order for a test to have access to the database it must either be marked
38-
using the :func:`~pytest.mark.django_db` mark or request one of the :fixture:`db`,
39-
:fixture:`transactional_db` or :fixture:`django_db_reset_sequences` fixtures.
40-
Otherwise the test will fail when trying to access the database.
41-
42-
:type transaction: bool
43-
:param transaction:
44-
The ``transaction`` argument will allow the test to use real transactions.
45-
With ``transaction=False`` (the default when not specified), transaction
46-
operations are noops during the test. This is the same behavior that
47-
:class:`django.test.TestCase` uses. When ``transaction=True``, the behavior
48-
will be the same as :class:`django.test.TransactionTestCase`.
49-
50-
51-
:type reset_sequences: bool
52-
:param reset_sequences:
53-
The ``reset_sequences`` argument will ask to reset auto increment sequence
54-
values (e.g. primary keys) before running the test. Defaults to
55-
``False``. Must be used together with ``transaction=True`` to have an
56-
effect. Please be aware that not all databases support this feature.
57-
For details see :attr:`django.test.TransactionTestCase.reset_sequences`.
58-
59-
60-
:type databases: Iterable[str] | str | None
61-
:param databases:
62-
63-
The ``databases`` argument defines which databases in a multi-database
64-
configuration will be set up and may be used by the test. Defaults to
65-
only the ``default`` database. The special value ``"__all__"`` may be used
66-
to specify all configured databases.
67-
For details see :attr:`django.test.TransactionTestCase.databases` and
68-
:attr:`django.test.TestCase.databases`.
69-
70-
:type serialized_rollback: bool
71-
:param serialized_rollback:
72-
The ``serialized_rollback`` argument enables :ref:`rollback emulation
73-
<test-case-serialized-rollback>`. After a transactional test (or any test
74-
using a database backend which doesn't support transactions) runs, the
75-
database is flushed, destroying data created in data migrations. Setting
76-
``serialized_rollback=True`` tells Django to serialize the database content
77-
during setup, and restore it during teardown.
78-
79-
Note that this will slow down that test suite by approximately 3x.
80-
81-
:type available_apps: Iterable[str] | None
82-
:param available_apps:
83-
.. caution::
84-
85-
This argument is **experimental** and is subject to change without
86-
deprecation.
87-
88-
The ``available_apps`` argument defines a subset of apps that are enabled
89-
for a specific set of tests. Setting ``available_apps`` configures models
90-
for which types/permissions will be created before each test, and which
91-
model tables will be emptied after each test (this truncation may cascade
92-
to unavailable apps models).
93-
94-
For details see :attr:`django.test.TransactionTestCase.available_apps`
31+
This is used to mark a test function as requiring the database. It
32+
will ensure the database is set up correctly for the test. Each test
33+
will run in its own transaction which will be rolled back at the end
34+
of the test. This behavior is the same as Django's standard
35+
:class:`~django.test.TestCase` class.
36+
37+
In order for a test to have access to the database it must either be marked
38+
using the :func:`~pytest.mark.django_db` mark or request one of the :fixture:`db`,
39+
:fixture:`transactional_db` or :fixture:`django_db_reset_sequences` fixtures.
40+
Otherwise the test will fail when trying to access the database.
41+
42+
:type transaction: bool
43+
:param transaction:
44+
The ``transaction`` argument will allow the test to use real transactions.
45+
With ``transaction=False`` (the default when not specified), transaction
46+
operations are noops during the test. This is the same behavior that
47+
:class:`django.test.TestCase` uses. When ``transaction=True``, the behavior
48+
will be the same as :class:`django.test.TransactionTestCase`.
49+
50+
51+
:type reset_sequences: bool
52+
:param reset_sequences:
53+
The ``reset_sequences`` argument will ask to reset auto increment sequence
54+
values (e.g. primary keys) before running the test. Defaults to
55+
``False``. Must be used together with ``transaction=True`` to have an
56+
effect. Please be aware that not all databases support this feature.
57+
For details see :attr:`django.test.TransactionTestCase.reset_sequences`.
58+
59+
60+
:type databases: Iterable[str] | str | None
61+
:param databases:
62+
63+
The ``databases`` argument defines which databases in a multi-database
64+
configuration will be set up and may be used by the test. Defaults to
65+
only the ``default`` database. The special value ``"__all__"`` may be used
66+
to specify all configured databases.
67+
For details see :attr:`django.test.TransactionTestCase.databases` and
68+
:attr:`django.test.TestCase.databases`.
69+
70+
:type serialized_rollback: bool
71+
:param serialized_rollback:
72+
The ``serialized_rollback`` argument enables :ref:`rollback emulation
73+
<test-case-serialized-rollback>`. After a transactional test (or any test
74+
using a database backend which doesn't support transactions) runs, the
75+
database is flushed, destroying data created in data migrations. Setting
76+
``serialized_rollback=True`` tells Django to serialize the database content
77+
during setup, and restore it during teardown.
78+
79+
Note that this will slow down that test suite by approximately 3x.
80+
81+
:type available_apps: Iterable[str] | None
82+
:param available_apps:
83+
.. caution::
84+
85+
This argument is **experimental** and is subject to change without
86+
deprecation.
87+
88+
The ``available_apps`` argument defines a subset of apps that are enabled
89+
for a specific set of tests. Setting ``available_apps`` configures models
90+
for which types/permissions will be created before each test, and which
91+
model tables will be emptied after each test (this truncation may cascade
92+
to unavailable apps models).
93+
94+
For details see :attr:`django.test.TransactionTestCase.available_apps`
9595

9696

9797
.. note::
9898

99-
If you want access to the Django database inside a *fixture*, this marker may
100-
or may not help even if the function requesting your fixture has this marker
101-
applied, depending on pytest's fixture execution order. To access the database
102-
in a fixture, it is recommended that the fixture explicitly request one of the
103-
:fixture:`db`, :fixture:`transactional_db`,
104-
:fixture:`django_db_reset_sequences` or
105-
:fixture:`django_db_serialized_rollback` fixtures. See below for a description
106-
of them.
99+
If you want access to the Django database inside a *fixture*, this marker may
100+
or may not help even if the function requesting your fixture has this marker
101+
applied, depending on pytest's fixture execution order. To access the database
102+
in a fixture, it is recommended that the fixture explicitly request one of the
103+
:fixture:`db`, :fixture:`transactional_db`,
104+
:fixture:`django_db_reset_sequences` or
105+
:fixture:`django_db_serialized_rollback` fixtures. See below for a description
106+
of them.
107107

108108
.. note:: Automatic usage with ``django.test.TestCase``.
109109

@@ -118,36 +118,36 @@ dynamically in a hook or fixture.
118118

119119
.. decorator:: pytest.mark.urls(urls)
120120

121-
Specify a different ``settings.ROOT_URLCONF`` module for the marked tests.
121+
Specify a different ``settings.ROOT_URLCONF`` module for the marked tests.
122122

123-
:type urls: str
124-
:param urls:
125-
The urlconf module to use for the test, e.g. ``myapp.test_urls``. This is
126-
similar to Django's ``TestCase.urls`` attribute.
123+
:type urls: str
124+
:param urls:
125+
The urlconf module to use for the test, e.g. ``myapp.test_urls``. This is
126+
similar to Django's ``TestCase.urls`` attribute.
127127

128-
Example usage::
128+
Example usage::
129129

130-
@pytest.mark.urls('myapp.test_urls')
131-
def test_something(client):
132-
assert b'Success!' in client.get('/some_url_defined_in_test_urls/').content
130+
@pytest.mark.urls('myapp.test_urls')
131+
def test_something(client):
132+
assert b'Success!' in client.get('/some_url_defined_in_test_urls/').content
133133

134134

135135
``pytest.mark.ignore_template_errors`` - ignore invalid template variables
136136
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
137137

138138
.. decorator:: pytest.mark.ignore_template_errors
139139

140-
Ignore errors when using the ``--fail-on-template-vars`` option, i.e.
141-
do not cause tests to fail if your templates contain invalid variables.
140+
Ignore errors when using the ``--fail-on-template-vars`` option, i.e.
141+
do not cause tests to fail if your templates contain invalid variables.
142142

143-
This marker sets the ``string_if_invalid`` template option.
144-
See :ref:`django:invalid-template-variables`.
143+
This marker sets the ``string_if_invalid`` template option.
144+
See :ref:`django:invalid-template-variables`.
145145

146-
Example usage::
146+
Example usage::
147147

148-
@pytest.mark.ignore_template_errors
149-
def test_something(client):
150-
client('some-url-with-invalid-template-vars')
148+
@pytest.mark.ignore_template_errors
149+
def test_something(client):
150+
client('some-url-with-invalid-template-vars')
151151

152152

153153
Fixtures
@@ -383,15 +383,15 @@ created in data migrations, you should add the
383383

384384
.. note:: Combining database access fixtures.
385385

386-
When using multiple database fixtures together, only one of them is
387-
used. Their order of precedence is as follows (the last one wins):
386+
When using multiple database fixtures together, only one of them is
387+
used. Their order of precedence is as follows (the last one wins):
388388

389-
* ``db``
390-
* ``transactional_db``
389+
* ``db``
390+
* ``transactional_db``
391391

392-
In addition, using ``live_server`` or ``django_db_reset_sequences`` will also
393-
trigger transactional database access, and ``django_db_serialized_rollback``
394-
regular database access, if not specified.
392+
In addition, using ``live_server`` or ``django_db_reset_sequences`` will also
393+
trigger transactional database access, and ``django_db_serialized_rollback``
394+
regular database access, if not specified.
395395

396396
.. fixture:: settings
397397

@@ -419,10 +419,10 @@ Example
419419

420420
.. py:function:: django_assert_num_queries(num, connection=None, info=None, *, using=None)
421421
422-
:param num: expected number of queries
423-
:param connection: optional database connection
424-
:param str info: optional info message to display on failure
425-
:param str using: optional database alias
422+
:param num: expected number of queries
423+
:param connection: optional database connection
424+
:param str info: optional info message to display on failure
425+
:param str using: optional database alias
426426

427427
This fixture allows to check for an expected number of DB queries.
428428

@@ -459,10 +459,10 @@ If you use type annotations, you can annotate the fixture like this::
459459

460460
.. py:function:: django_assert_max_num_queries(num, connection=None, info=None, *, using=None)
461461
462-
:param num: expected maximum number of queries
463-
:param connection: optional database connection
464-
:param str info: optional info message to display on failure
465-
:param str using: optional database alias
462+
:param num: expected maximum number of queries
463+
:param connection: optional database connection
464+
:param str info: optional info message to display on failure
465+
:param str using: optional database alias
466466

467467
This fixture allows to check for an expected maximum number of DB queries.
468468

@@ -492,12 +492,12 @@ If you use type annotations, you can annotate the fixture like this::
492492

493493
.. py:function:: django_capture_on_commit_callbacks(*, using=DEFAULT_DB_ALIAS, execute=False)
494494
495-
:param using:
496-
The alias of the database connection to capture callbacks for.
497-
:param execute:
498-
If True, all the callbacks will be called as the context manager exits, if
499-
no exception occurred. This emulates a commit after the wrapped block of
500-
code.
495+
:param using:
496+
The alias of the database connection to capture callbacks for.
497+
:param execute:
498+
If True, all the callbacks will be called as the context manager exits, if
499+
no exception occurred. This emulates a commit after the wrapped block of
500+
code.
501501

502502
.. versionadded:: 4.4
503503

docs/index.rst

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Quick Start
1313

1414
.. code-block:: bash
1515
16-
$ pip install pytest-django
16+
$ pip install pytest-django
1717
1818
Make sure ``DJANGO_SETTINGS_MODULE`` is defined (see
1919
:ref:`configuring_django_settings`) and make your tests discoverable
@@ -24,28 +24,28 @@ Example using pytest.ini or tox.ini
2424

2525
.. code-block:: ini
2626
27-
# -- FILE: pytest.ini (or tox.ini)
28-
[pytest]
29-
DJANGO_SETTINGS_MODULE = test.settings
30-
# -- recommended but optional:
31-
python_files = tests.py test_*.py *_tests.py
27+
# -- FILE: pytest.ini (or tox.ini)
28+
[pytest]
29+
DJANGO_SETTINGS_MODULE = test.settings
30+
# -- recommended but optional:
31+
python_files = tests.py test_*.py *_tests.py
3232
3333
Example using pyproject.toml
3434
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3535

3636
.. code-block:: toml
3737
38-
# -- Example FILE: pyproject.toml
39-
[tool.pytest.ini_options]
40-
DJANGO_SETTINGS_MODULE = "test.settings"
41-
# -- recommended but optional:
42-
python_files = ["test_*.py", "*_test.py", "testing/python/*.py"]
38+
# -- Example FILE: pyproject.toml
39+
[tool.pytest.ini_options]
40+
DJANGO_SETTINGS_MODULE = "test.settings"
41+
# -- recommended but optional:
42+
python_files = ["test_*.py", "*_test.py", "testing/python/*.py"]
4343
4444
Run your tests with ``pytest``:
4545

4646
.. code-block:: bash
4747
48-
$ pytest
48+
$ pytest
4949
5050
Why would I use this instead of Django's manage.py test command?
5151
================================================================
@@ -73,17 +73,17 @@ Table of Contents
7373
=================
7474

7575
.. toctree::
76-
:maxdepth: 3
77-
78-
tutorial
79-
configuring_django
80-
managing_python_path
81-
usage
82-
database
83-
helpers
84-
faq
85-
contributing
86-
changelog
76+
:maxdepth: 3
77+
78+
tutorial
79+
configuring_django
80+
managing_python_path
81+
usage
82+
database
83+
helpers
84+
faq
85+
contributing
86+
changelog
8787

8888
Indices and Tables
8989
==================

docs/managing_python_path.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ You can explicitly add paths to the Python search path using pytest's
8787
Example: project with src layout
8888
````````````````````````````````
8989

90-
For a Django package using the ``src`` layout, with test settings located in a
90+
For a Django package using the ``src`` layout, with test settings located in a
9191
``tests`` package at the top level::
9292

9393
myproj

docs/usage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ You can switch it on in `pytest.ini`::
3333

3434
[pytest]
3535
FAIL_INVALID_TEMPLATE_VARS = True
36-
36+
3737
Additional pytest.ini settings
3838
------------------------------
3939

0 commit comments

Comments
 (0)