From 90f3c2f0308162aa08ffdb14bd148edc7576b469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20=C3=89vrard?= Date: Fri, 17 Oct 2025 16:27:11 +0200 Subject: [PATCH] Compare the default fields used in copy with those of the calling class Closes #14298 --- trytond/trytond/tests/test_tryton.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/trytond/trytond/tests/test_tryton.py b/trytond/trytond/tests/test_tryton.py index d0d5008e7a..f257cc48de 100644 --- a/trytond/trytond/tests/test_tryton.py +++ b/trytond/trytond/tests/test_tryton.py @@ -901,7 +901,9 @@ class ModuleTestCase(_DBTestCase): @with_transaction() def test_modelstorage_copy(self): "Test copied default values" - with unittest.mock.patch.object(ModelStorage, 'copy') as copy: + copy = unittest.mock.Mock() + with unittest.mock.patch.object( + ModelStorage, 'copy', new=classmethod(copy)): for mname, model in Pool().iterobject(): if not isregisteredby(model, self.module): continue @@ -910,7 +912,7 @@ class ModuleTestCase(_DBTestCase): with self.subTest(model=mname): model.copy([]) if copy.call_args: - args, kwargs = copy.call_args + (klass, *args), kwargs = copy.call_args if len(args) >= 2: default = args[1] else: @@ -918,7 +920,7 @@ class ModuleTestCase(_DBTestCase): if default is not None: fields = { k.split('.', 1)[0] for k in default.keys()} - self.assertLessEqual(fields, model._fields.keys()) + self.assertLessEqual(fields, klass._fields.keys()) copy.reset_mock() @with_transaction()