details: https://code.tryton.org/tryton/commit/f5d236a74873
branch: default
user: Nicolas Évrard <[email protected]>
date: Fri Oct 17 16:27:11 2025 +0200
description:
Compare the default fields used in copy with those of the calling class
Closes #14298
diffstat:
trytond/trytond/tests/test_tryton.py | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diffs (32 lines):
diff -r ddc5c147c78b -r f5d236a74873 trytond/trytond/tests/test_tryton.py
--- a/trytond/trytond/tests/test_tryton.py Tue Oct 07 12:42:44 2025 +0200
+++ b/trytond/trytond/tests/test_tryton.py Fri Oct 17 16:27:11 2025 +0200
@@ -901,7 +901,9 @@
@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 @@
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 @@
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()