details: https://code.tryton.org/tryton/commit/6d803245a3e4
branch: 7.6
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
(grafted from f5d236a74873447fdc1742782148f0b91ff31e09)
diffstat:
trytond/trytond/tests/test_tryton.py | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diffs (32 lines):
diff -r 95573f6cfdb7 -r 6d803245a3e4 trytond/trytond/tests/test_tryton.py
--- a/trytond/trytond/tests/test_tryton.py Fri Oct 17 10:33:06 2025 +0000
+++ b/trytond/trytond/tests/test_tryton.py Fri Oct 17 16:27:11 2025 +0200
@@ -898,7 +898,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
@@ -907,7 +909,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:
@@ -915,7 +917,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()