From 512d0f189015b3a0d28725bc72428a8e8b8967bb Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Tue, 16 Apr 2024 03:59:50 +0200 Subject: [PATCH] Avoid deprecated `SoftDeletableModel.objects` manager in tests Use the `available_objects` manager instead. --- tests/models.py | 2 +- tests/test_managers/test_softdelete_manager.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/models.py b/tests/models.py index 442200f2..ac65931c 100644 --- a/tests/models.py +++ b/tests/models.py @@ -360,7 +360,7 @@ def only_read(self): class CustomSoftDelete(SoftDeletableModel): is_read = models.BooleanField(default=False) - objects = SoftDeletableManager.from_queryset(CustomSoftDeleteQuerySet)() # type: ignore[misc] + available_objects = SoftDeletableManager.from_queryset(CustomSoftDeleteQuerySet)() # type: ignore[misc] class StringyDescriptor: diff --git a/tests/test_managers/test_softdelete_manager.py b/tests/test_managers/test_softdelete_manager.py index db495c4a..aec53576 100644 --- a/tests/test_managers/test_softdelete_manager.py +++ b/tests/test_managers/test_softdelete_manager.py @@ -6,21 +6,21 @@ class CustomSoftDeleteManagerTests(TestCase): def test_custom_manager_empty(self): - qs = CustomSoftDelete.objects.only_read() + qs = CustomSoftDelete.available_objects.only_read() self.assertEqual(qs.count(), 0) def test_custom_qs_empty(self): - qs = CustomSoftDelete.objects.all().only_read() + qs = CustomSoftDelete.available_objects.all().only_read() self.assertEqual(qs.count(), 0) def test_is_read(self): for is_read in [True, False, True, False]: - CustomSoftDelete.objects.create(is_read=is_read) - qs = CustomSoftDelete.objects.only_read() + CustomSoftDelete.available_objects.create(is_read=is_read) + qs = CustomSoftDelete.available_objects.only_read() self.assertEqual(qs.count(), 2) def test_is_read_removed(self): for is_read, is_removed in [(True, True), (True, False), (False, False), (False, True)]: - CustomSoftDelete.objects.create(is_read=is_read, is_removed=is_removed) - qs = CustomSoftDelete.objects.only_read() + CustomSoftDelete.available_objects.create(is_read=is_read, is_removed=is_removed) + qs = CustomSoftDelete.available_objects.only_read() self.assertEqual(qs.count(), 1)