diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 46c404e8..e3445417 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -67,3 +67,8 @@ repos: hooks: - id: pyupgrade args: [--py310-plus] + + - repo: https://github.com/adamchainz/django-upgrade + rev: 1.29.1 + hooks: + - id: django-upgrade diff --git a/simple_history/tests/admin.py b/simple_history/tests/admin.py index cc6aaf90..83d2fe75 100644 --- a/simple_history/tests/admin.py +++ b/simple_history/tests/admin.py @@ -21,6 +21,7 @@ ) +@admin.register(Person) class PersonAdmin(SimpleHistoryAdmin): def has_change_permission(self, request, obj=None): return False @@ -29,10 +30,12 @@ def has_view_permission(self, request, obj=None): return False +@admin.register(Choice) class ChoiceAdmin(SimpleHistoryAdmin): history_list_display = ["votes"] +@admin.register(FileModel) class FileModelAdmin(SimpleHistoryAdmin): def test_method(self, obj): return "test_method_value" @@ -40,6 +43,7 @@ def test_method(self, obj): history_list_display = ["title", "test_method"] +@admin.register(Planet) class PlanetAdmin(SimpleHistoryAdmin): def test_method(self, obj): return "test_method_value" @@ -63,20 +67,16 @@ def place_display(place: Place) -> SafeString: return mark_safe(f"{place.name}") +@admin.register(PollWithManyToMany) class PollWithManyToManyAdmin(SimpleHistoryAdmin): def get_historical_record_context_helper(self, request, historical_record): return HistoricalPollWithManyToManyContextHelper(self.model, historical_record) admin.site.register(Book, SimpleHistoryAdmin) -admin.site.register(Choice, ChoiceAdmin) admin.site.register(ConcreteExternal, SimpleHistoryAdmin) admin.site.register(Document, SimpleHistoryAdmin) admin.site.register(Employee, SimpleHistoryAdmin) admin.site.register(ExternalModelWithCustomUserIdField, SimpleHistoryAdmin) -admin.site.register(FileModel, FileModelAdmin) admin.site.register(Paper, SimpleHistoryAdmin) -admin.site.register(Person, PersonAdmin) -admin.site.register(Planet, PlanetAdmin) admin.site.register(Poll, SimpleHistoryAdmin) -admin.site.register(PollWithManyToMany, PollWithManyToManyAdmin) diff --git a/simple_history/tests/tests/test_utils.py b/simple_history/tests/tests/test_utils.py index 7db701d9..a009322d 100644 --- a/simple_history/tests/tests/test_utils.py +++ b/simple_history/tests/tests/test_utils.py @@ -495,7 +495,6 @@ def test_bulk_update_history_with_batch_size(self): self.assertEqual(Poll.objects.count(), 5) self.assertEqual(Poll.history.filter(history_type="~").count(), 5) - @skipUnless(django.VERSION >= (4, 0), "Requires Django 4.0 or above") def test_bulk_update_with_history_returns_rows_updated(self): rows_updated = bulk_update_with_history( self.data, diff --git a/simple_history/tests/urls.py b/simple_history/tests/urls.py index acb6cb12..652e697b 100644 --- a/simple_history/tests/urls.py +++ b/simple_history/tests/urls.py @@ -1,5 +1,5 @@ from django.contrib import admin -from django.urls import path, re_path +from django.urls import path from simple_history.tests.view import ( BucketDataRegisterRequestUserCreate, @@ -29,8 +29,8 @@ BucketDataRegisterRequestUserCreate.as_view(), name="bucket_data-add", ), - re_path( - r"^bucket_data/(?P[0-9]+)/$", + path( + "bucket_data//", BucketDataRegisterRequestUserDetail.as_view(), name="bucket_data-detail", ), @@ -40,9 +40,9 @@ PollWithHistoricalIPAddressCreate.as_view(), name="pollip-add", ), - re_path(r"^poll/(?P[0-9]+)/$", PollUpdate.as_view(), name="poll-update"), - re_path(r"^poll/(?P[0-9]+)/delete/$", PollDelete.as_view(), name="poll-delete"), - re_path(r"^polls/(?P[0-9]+)/$", PollDetail.as_view(), name="poll-detail"), + path("poll//", PollUpdate.as_view(), name="poll-update"), + path("poll//delete/", PollDelete.as_view(), name="poll-delete"), + path("polls//", PollDetail.as_view(), name="poll-detail"), path("polls/", PollList.as_view(), name="poll-list"), path("polls-bulk-create/", PollBulkCreateView.as_view(), name="poll-bulk-create"), path(