diff --git a/docs/changelog.rst b/docs/changelog.rst index ee4a06d5..d120e7cc 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,6 +1,16 @@ Changelog ========= +v4.5.2 (2021-12-07) +------------------- + +Bugfixes +^^^^^^^^ + +* Fix regression in v4.5.0 - ``pytest.mark.django_db(reset_sequence=True)`` now + implies ``transaction=True`` again. + + v4.5.1 (2021-12-02) ------------------- diff --git a/pytest_django/fixtures.py b/pytest_django/fixtures.py index 9cb73269..36020dcc 100644 --- a/pytest_django/fixtures.py +++ b/pytest_django/fixtures.py @@ -167,7 +167,7 @@ def _django_db_helper( serialized_rollback, ) = False, False, None, False - transactional = transactional or ( + transactional = transactional or reset_sequences or ( "transactional_db" in request.fixturenames or "live_server" in request.fixturenames ) diff --git a/tests/test_database.py b/tests/test_database.py index df0d6470..510f4bff 100644 --- a/tests/test_database.py +++ b/tests/test_database.py @@ -287,11 +287,16 @@ def test_reset_sequences_disabled(self, request) -> None: marker = request.node.get_closest_marker("django_db") assert not marker.kwargs - @pytest.mark.django_db(transaction=True, reset_sequences=True) + @pytest.mark.django_db(reset_sequences=True) def test_reset_sequences_enabled(self, request) -> None: marker = request.node.get_closest_marker("django_db") assert marker.kwargs["reset_sequences"] + @pytest.mark.django_db(transaction=True, reset_sequences=True) + def test_transaction_reset_sequences_enabled(self, request) -> None: + marker = request.node.get_closest_marker("django_db") + assert marker.kwargs["reset_sequences"] + @pytest.mark.django_db(databases=['default', 'replica', 'second']) def test_databases(self, request) -> None: marker = request.node.get_closest_marker("django_db")