Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ Changelog
v4.12.1 (unreleased)
--------------------

Improvements
^^^^^^^^^^^^

* Re-export ``pytest_django.SettingsWrapper`` from the top-level
``pytest_django`` namespace so the :fixture:`settings` fixture can be
type-annotated without reaching into ``pytest_django.fixtures``
(`#1257 <https://github.com/pytest-dev/pytest-django/issues/1257>`__).

Bugfixes
^^^^^^^^

Expand Down
7 changes: 7 additions & 0 deletions docs/helpers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,13 @@ Example
settings.USE_TZ = True
assert settings.USE_TZ

If you use type annotations, you can annotate the fixture like this::

from pytest_django import SettingsWrapper

def test_with_specific_settings(settings: SettingsWrapper):
...


.. fixture:: django_assert_num_queries

Expand Down
3 changes: 2 additions & 1 deletion pytest_django/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
__version__ = "unknown"


from .fixtures import DjangoAssertNumQueries, DjangoCaptureOnCommitCallbacks
from .fixtures import DjangoAssertNumQueries, DjangoCaptureOnCommitCallbacks, SettingsWrapper
from .plugin import DjangoDbBlocker


__all__ = [
"DjangoAssertNumQueries",
"DjangoCaptureOnCommitCallbacks",
"DjangoDbBlocker",
"SettingsWrapper",
"__version__",
]
7 changes: 7 additions & 0 deletions tests/test_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,13 @@ def test_set_non_existent(settings):
]
)

def test_settings_wrapper_is_publicly_reexported(self) -> None:
import pytest_django
from pytest_django.fixtures import SettingsWrapper as _Wrapper

assert "SettingsWrapper" in pytest_django.__all__
assert pytest_django.SettingsWrapper is _Wrapper


class TestLiveServer:
@pytest.mark.skipif("PYTEST_XDIST_WORKER" in os.environ, reason="xdist in use")
Expand Down