Skip to content

Commit

Permalink
Make pytest.mark.django_db(reset_sequences=True) imply `transaction…
Browse files Browse the repository at this point in the history
…=True` again

Regressed in `4.5.0`. Though it would have been better if it hadn't,
changing it now is a breaking change so needs to be fixed.
  • Loading branch information
bluetech committed Dec 7, 2021
1 parent b97a8b1 commit 3bc9065
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
10 changes: 10 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -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)
-------------------

Expand Down
2 changes: 1 addition & 1 deletion pytest_django/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
7 changes: 6 additions & 1 deletion tests/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 3bc9065

Please sign in to comment.