1
0
mirror of https://github.com/django/django.git synced 2025-10-27 23:56:08 +00:00

Refs #35060 -- Removed passing positional arguments to Model.save()/asave() per deprecation timeline.

This commit is contained in:
Sarah Boyce
2024-12-13 09:16:03 +01:00
parent 8d695bf510
commit d5fec03dad
6 changed files with 8 additions and 243 deletions

View File

@@ -1,6 +1,5 @@
from django.db.models.signals import post_save, pre_save
from django.test import TestCase
from django.utils.deprecation import RemovedInDjango60Warning
from .models import Account, Employee, Person, Profile, ProxyEmployee
@@ -257,31 +256,6 @@ class UpdateOnlyFieldsTests(TestCase):
pre_save.disconnect(pre_save_receiver)
post_save.disconnect(post_save_receiver)
def test_empty_update_fields_positional_save(self):
s = Person.objects.create(name="Sara", gender="F")
msg = "Passing positional arguments to save() is deprecated"
with (
self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx,
self.assertNumQueries(0),
):
s.save(False, False, None, [])
self.assertEqual(ctx.filename, __file__)
async def test_empty_update_fields_positional_asave(self):
s = await Person.objects.acreate(name="Sara", gender="F")
# Workaround for a lack of async assertNumQueries.
s.name = "Other"
msg = "Passing positional arguments to asave() is deprecated"
with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx:
await s.asave(False, False, None, [])
self.assertEqual(ctx.filename, __file__)
# No save occurred for an empty update_fields.
await s.arefresh_from_db()
self.assertEqual(s.name, "Sara")
def test_num_queries_inheritance(self):
s = Employee.objects.create(name="Sara", gender="F")
s.employee_num = 1