changeset a3df1b17977c in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset&node=a3df1b17977c
description:
Ensure that objects in the Pool has __slots__
issue10719
review375361002
diffstat:
CHANGELOG | 1 +
trytond/ir/avatar.py | 1 +
trytond/model/avatar.py | 2 +-
trytond/tests/mixin.py | 8 ++++----
trytond/tests/test_tryton.py | 16 ++++++++++++++++
5 files changed, 23 insertions(+), 5 deletions(-)
diffs (84 lines):
diff -r 5c8a9ffc956a -r a3df1b17977c CHANGELOG
--- a/CHANGELOG Thu Sep 23 10:39:41 2021 +0200
+++ b/CHANGELOG Thu Sep 23 23:12:35 2021 +0200
@@ -1,3 +1,4 @@
+* Ensure with a test that objects in the Pool have __slots__
* Use bigdecimal tag for XML-RPC
* Use tuple in Dict value instead of list
* Do not set record name on title of report get_email
diff -r 5c8a9ffc956a -r a3df1b17977c trytond/ir/avatar.py
--- a/trytond/ir/avatar.py Thu Sep 23 10:39:41 2021 +0200
+++ b/trytond/ir/avatar.py Thu Sep 23 23:12:35 2021 +0200
@@ -32,6 +32,7 @@
class ImageMixin:
+ __slots__ = ()
image = fields.Binary(
"Image", file_id=file_id, store_prefix=store_prefix)
image_id = fields.Char("Image ID", readonly=True)
diff -r 5c8a9ffc956a -r a3df1b17977c trytond/model/avatar.py
--- a/trytond/model/avatar.py Thu Sep 23 10:39:41 2021 +0200
+++ b/trytond/model/avatar.py Thu Sep 23 23:12:35 2021 +0200
@@ -8,7 +8,7 @@
def avatar_mixin(size=64, default=None):
class AvatarMixin:
-
+ __slots__ = ()
avatars = fields.One2Many(
'ir.avatar', 'resource', lazy_gettext('ir.msg_avatars'), size=1)
avatar = fields.Function(
diff -r 5c8a9ffc956a -r a3df1b17977c trytond/tests/mixin.py
--- a/trytond/tests/mixin.py Thu Sep 23 10:39:41 2021 +0200
+++ b/trytond/tests/mixin.py Thu Sep 23 23:12:35 2021 +0200
@@ -6,19 +6,19 @@
class TestMixin:
- pass
+ __slots__ = ()
class TestSecondMixin:
- pass
+ __slots__ = ()
class NotMixin:
- pass
+ __slots__ = ()
class ReportMixin:
- pass
+ __slots__ = ()
class DeactivableModelView(DeactivableMixin, ModelView):
diff -r 5c8a9ffc956a -r a3df1b17977c trytond/tests/test_tryton.py
--- a/trytond/tests/test_tryton.py Thu Sep 23 10:39:41 2021 +0200
+++ b/trytond/tests/test_tryton.py Thu Sep 23 23:12:35 2021 +0200
@@ -745,6 +745,22 @@
"classes of '%s'." % mname)
@with_transaction()
+ def test_pool_slots(self):
+ "Test pool object has __slots__"
+ for type_ in ['model', 'wizard', 'report']:
+ for name, cls in Pool().iterobject(type_):
+ if not isregisteredby(cls, self.module):
+ continue
+ if getattr(cls, '__no_slots__', None):
+ continue
+ for kls in cls.__mro__:
+ if kls is object:
+ continue
+ self.assertTrue(hasattr(kls, '__slots__'),
+ msg="The %s of %s '%s' has no __slots__"
+ % (kls, type_, name))
+
+ @with_transaction()
def test_buttons_registered(self):
'Test all buttons are registered in ir.model.button'
pool = Pool()