Skip to content

Commit b373db6

Browse files
authored
Add docstrings to public fixtures (#1135)
1 parent 3d3a842 commit b373db6

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

pytest_django/fixtures.py

+7
Original file line numberDiff line numberDiff line change
@@ -94,22 +94,26 @@ def django_db_modify_db_settings_parallel_suffix(
9494
def django_db_modify_db_settings(
9595
django_db_modify_db_settings_parallel_suffix: None,
9696
) -> None:
97+
"""Modify db settings just before the databases are configured."""
9798
skip_if_no_django()
9899

99100

100101
@pytest.fixture(scope="session")
101102
def django_db_use_migrations(request: pytest.FixtureRequest) -> bool:
103+
"""Return whether to use migrations to create the test databases."""
102104
return not request.config.getvalue("nomigrations")
103105

104106

105107
@pytest.fixture(scope="session")
106108
def django_db_keepdb(request: pytest.FixtureRequest) -> bool:
109+
"""Return whether to re-use an existing database and to keep it after the test run."""
107110
reuse_db: bool = request.config.getvalue("reuse_db")
108111
return reuse_db
109112

110113

111114
@pytest.fixture(scope="session")
112115
def django_db_createdb(request: pytest.FixtureRequest) -> bool:
116+
"""Return whether the database is to be re-created before running any tests."""
113117
create_db: bool = request.config.getvalue("create_db")
114118
return create_db
115119

@@ -656,11 +660,13 @@ def _assert_num_queries(
656660

657661
@pytest.fixture()
658662
def django_assert_num_queries(pytestconfig: pytest.Config) -> DjangoAssertNumQueries:
663+
"""Allows to check for an expected number of DB queries."""
659664
return partial(_assert_num_queries, pytestconfig)
660665

661666

662667
@pytest.fixture()
663668
def django_assert_max_num_queries(pytestconfig: pytest.Config) -> DjangoAssertNumQueries:
669+
"""Allows to check for an expected maximum number of DB queries."""
664670
return partial(_assert_num_queries, pytestconfig, exact=False)
665671

666672

@@ -678,6 +684,7 @@ def __call__(
678684

679685
@pytest.fixture()
680686
def django_capture_on_commit_callbacks() -> DjangoCaptureOnCommitCallbacks:
687+
"""Captures transaction.on_commit() callbacks for the given database connection."""
681688
from django.test import TestCase
682689

683690
return TestCase.captureOnCommitCallbacks # type: ignore[no-any-return]

pytest_django/plugin.py

+3
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ def mailoutbox(
578578
django_mail_patch_dns: None,
579579
_dj_autoclear_mailbox: None,
580580
) -> list[django.core.mail.EmailMessage] | None:
581+
"""A clean email outbox to which Django-generated emails are sent."""
581582
if not django_settings_is_configured():
582583
return None
583584

@@ -591,13 +592,15 @@ def django_mail_patch_dns(
591592
monkeypatch: pytest.MonkeyPatch,
592593
django_mail_dnsname: str,
593594
) -> None:
595+
"""Patch the server dns name used in email messages."""
594596
from django.core import mail
595597

596598
monkeypatch.setattr(mail.message, "DNS_NAME", django_mail_dnsname)
597599

598600

599601
@pytest.fixture()
600602
def django_mail_dnsname() -> str:
603+
"""Return server dns name for using in email messages."""
601604
return "fake-tests.example.com"
602605

603606

0 commit comments

Comments
 (0)