Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#1258)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/asottile/pyupgrade: v3.10.1 → v3.11.0](asottile/pyupgrade@v3.10.1...v3.11.0)

* Replaced deprecated assertQuerysetEqual()

...with `assertQuerySetEqual()` (notice the uppercase S in "QuerySet"),
when Django is 4.2 or higher.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Anders <6058745+ddabble@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] and ddabble authored Sep 25, 2023
1 parent aa87e7c commit fc1b3db
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ repos:
- "--strict"

- repo: https://github.com/asottile/pyupgrade
rev: v3.10.1
rev: v3.11.0
hooks:
- id: pyupgrade
args: [--py38-plus]
19 changes: 17 additions & 2 deletions simple_history/tests/tests/test_manager.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import datetime, timedelta
from operator import attrgetter

import django
from django.contrib.auth import get_user_model
from django.db import IntegrityError
from django.test import TestCase, override_settings, skipUnlessDBFeature
Expand Down Expand Up @@ -198,10 +199,17 @@ def setUp(self):
Poll(id=4, question="Question 4", pub_date=datetime.now()),
]

# DEV: Remove this method when the minimum required Django version is 4.2
def assertQuerySetEqual(self, *args, **kwargs):
if django.VERSION < (4, 2):
return self.assertQuerysetEqual(*args, **kwargs)
else:
return super().assertQuerySetEqual(*args, **kwargs)

def test_simple_bulk_history_create(self):
created = Poll.history.bulk_history_create(self.data)
self.assertEqual(len(created), 4)
self.assertQuerysetEqual(
self.assertQuerySetEqual(
Poll.history.order_by("question"),
["Question 1", "Question 2", "Question 3", "Question 4"],
attrgetter("question"),
Expand Down Expand Up @@ -326,10 +334,17 @@ def setUp(self):
Poll(id=4, question="Question 4", pub_date=datetime.now()),
]

# DEV: Remove this method when the minimum required Django version is 4.2
def assertQuerySetEqual(self, *args, **kwargs):
if django.VERSION < (4, 2):
return self.assertQuerysetEqual(*args, **kwargs)
else:
return super().assertQuerySetEqual(*args, **kwargs)

def test_simple_bulk_history_create(self):
created = Poll.history.bulk_history_create(self.data, update=True)
self.assertEqual(len(created), 4)
self.assertQuerysetEqual(
self.assertQuerySetEqual(
Poll.history.order_by("question"),
["Question 1", "Question 2", "Question 3", "Question 4"],
attrgetter("question"),
Expand Down

0 comments on commit fc1b3db

Please sign in to comment.