Skip to content

Commit

Permalink
Always set reset_sequences on the test class according to the given…
Browse files Browse the repository at this point in the history
… value

This way Django will warn about any misuses and we don't rely on
defaults.
  • Loading branch information
bluetech committed Nov 28, 2021
1 parent 3a7ed7a commit 8433d5b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions pytest_django/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ def _django_db_helper(
_databases = databases

class PytestDjangoTestCase(test_case_class): # type: ignore[misc,valid-type]
if transactional and _reset_sequences:
reset_sequences = True
reset_sequences = _reset_sequences
if _databases is not None:
databases = _databases

Expand Down
2 changes: 1 addition & 1 deletion tests/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def test_reset_sequences_disabled(self, request) -> None:
marker = request.node.get_closest_marker("django_db")
assert not marker.kwargs

@pytest.mark.django_db(reset_sequences=True)
@pytest.mark.django_db(transaction=True, reset_sequences=True)
def test_reset_sequences_enabled(self, request) -> None:
marker = request.node.get_closest_marker("django_db")
assert marker.kwargs["reset_sequences"]
Expand Down

0 comments on commit 8433d5b

Please sign in to comment.