[PATCH 2 of 2 compound] Add a message to explain assertion failure

Sylvain Thenault sylvain.thenault at logilab.fr
Tue Mar 21 09:59:18 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1490086652 -3600
#      Tue Mar 21 09:57:32 2017 +0100
# Node ID a653885d3c831bb3342f4c8ffce906a041423dba
# Parent  e6bc30cf82138177545fa76d28c7ba3e672303e9
Add a message to explain assertion failure

diff --git a/cubicweb_compound/entities.py b/cubicweb_compound/entities.py
--- a/cubicweb_compound/entities.py
+++ b/cubicweb_compound/entities.py
@@ -103,11 +103,14 @@ class IContained(EntityAdapter):
                     parent_relation[-1] in ('subject', 'object')), parent_relation
         # use already created class if any
         if etype in cls._classes:
             contained_cls = cls._classes[etype]
             # ensure registered class is the same at the one that would be generated
-            assert contained_cls.__bases__ == (cls,)
+            assert contained_cls.__bases__ == (cls,), (
+                'Attempt to build a IContained implementation for {etype} using'
+                ' {cls} as base class, but an implementation based on {bases} '
+                'already exists'.format(etype=etype, cls=cls, bases=contained_cls.__bases__))
             contained_cls.parent_relations |= parent_relations
             return None
         # else generate one
         else:
             selector = is_instance(etype)


More information about the saem-devel mailing list