From fc1b3db5edbbec7084bc8fbad1b9b1ab27fd4771 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 25 Sep 2023 19:33:54 +0200 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#1258) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/asottile/pyupgrade: v3.10.1 → v3.11.0](https://github.com/asottile/pyupgrade/compare/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> --- .pre-commit-config.yaml | 2 +- simple_history/tests/tests/test_manager.py | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5eba466aa..0bb0910ba 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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] diff --git a/simple_history/tests/tests/test_manager.py b/simple_history/tests/tests/test_manager.py index 894019f91..30e5ec11a 100644 --- a/simple_history/tests/tests/test_manager.py +++ b/simple_history/tests/tests/test_manager.py @@ -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 @@ -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"), @@ -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"),