davemds pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=e7a26af3302784ef30fe26cd1a5801cba155b1b2
commit e7a26af3302784ef30fe26cd1a5801cba155b1b2 Author: Dave Andreoli <d...@gurumeditation.it> Date: Mon Jan 1 08:35:39 2018 +0100 Pyolian: better equality test, new hierarchy prop and some tests --- src/scripts/pyolian/eolian.py | 21 +++++++++++++++++---- src/scripts/pyolian/test_eolian.py | 22 +++++++++++++++++++++- src/scripts/pyolian/test_gen_class.template | 14 ++++++++++++-- 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/src/scripts/pyolian/eolian.py b/src/scripts/pyolian/eolian.py index ced4934f2e..a5653a5120 100644 --- a/src/scripts/pyolian/eolian.py +++ b/src/scripts/pyolian/eolian.py @@ -272,7 +272,14 @@ class EolianBaseObject(object): type(c_obj_pointer), self.__class__.__name__)) def __eq__(self, other): - return self._obj.value == other._obj.value + if isinstance(other, EolianBaseObject): + return self._obj.value == other._obj.value + elif isinstance(other, str): + if hasattr(self, 'full_name'): + return self.full_name == other + elif hasattr(self, 'name'): + return self.name == other + return False def __hash__(self): return self._obj.value @@ -499,6 +506,15 @@ class Class(EolianBaseObject): return L @property + def hierarchy(self): + L = [] + base = self.base_class + while base: + L.append(base) + base = base.base_class + return L + + @property def base_class(self): inherits = list(self.inherits) if len(inherits) > 0: @@ -884,9 +900,6 @@ class Implement(EolianBaseObject): def is_method(self): return not self.is_property - def is_overridden(self, cls): - return cls.name == self.class_.name # TODO equality inside class - class Type(EolianBaseObject): # OK (4 eolian issue) def __repr__(self): diff --git a/src/scripts/pyolian/test_eolian.py b/src/scripts/pyolian/test_eolian.py index 24b76c5686..76baf887f2 100755 --- a/src/scripts/pyolian/test_eolian.py +++ b/src/scripts/pyolian/test_eolian.py @@ -30,12 +30,27 @@ class TestBaseObject(unittest.TestCase): self.assertIsInstance(cls1, eolian.Class) self.assertIsInstance(cls2, eolian.Class) self.assertEqual(cls1, cls2) + self.assertEqual(cls1, 'Efl.Loop.Timer') + self.assertEqual(cls2, 'Efl.Loop.Timer') + self.assertNotEqual(cls1, 'another string') + self.assertNotEqual(cls1, 1234) + self.assertNotEqual(cls1, None) + self.assertNotEqual(cls1, 0) enum1 = state.typedecl_enum_get_by_name('Efl.Ui.Focus.Direction') enum2 = state.typedecl_enum_get_by_name('Efl.Ui.Focus.Direction') self.assertIsInstance(enum1, eolian.Typedecl) self.assertIsInstance(enum2, eolian.Typedecl) self.assertEqual(enum1, enum2) + self.assertEqual(enum1, 'Efl.Ui.Focus.Direction') + self.assertEqual(enum2, 'Efl.Ui.Focus.Direction') + self.assertNotEqual(enum1, 'another string') + self.assertNotEqual(enum1, 1234) + self.assertNotEqual(enum1, None) + self.assertNotEqual(enum1, 0) + + self.assertNotEqual(cls1, enum1) + class TestEolianUnit(unittest.TestCase): @@ -152,7 +167,10 @@ class TestEolianClass(unittest.TestCase): self.assertIsNone(cls.eo_prefix) # TODO fin a class with a value self.assertIsNone(cls.event_prefix) # TODO same as above self.assertIsNone(cls.data_type) # TODO same as above - self.assertEqual(len(list(cls.inherits)), 1) + self.assertEqual(cls.base_class.full_name, 'Efl.Loop.Consumer') + self.assertEqual([c.full_name for c in cls.inherits], ['Efl.Loop.Consumer']) + self.assertEqual([c.full_name for c in cls.inherits_full], ['Efl.Loop.Consumer', 'Efl.Object']) + self.assertEqual([c.full_name for c in cls.hierarchy], ['Efl.Loop.Consumer', 'Efl.Object']) self.assertFalse(cls.ctor_enable) self.assertFalse(cls.dtor_enable) self.assertEqual(cls.c_get_function_name, 'efl_loop_timer_class_get') @@ -225,6 +243,8 @@ class TestEolianImplement(unittest.TestCase): self.assertFalse(im.is_pure_virtual()) self.assertFalse(im.is_prop_set) self.assertFalse(im.is_prop_get) + self.assertFalse(im.is_property) + self.assertTrue(im.is_method) class TestEolianEvent(unittest.TestCase): diff --git a/src/scripts/pyolian/test_gen_class.template b/src/scripts/pyolian/test_gen_class.template index 7f03b5edd2..ff8c17de62 100644 --- a/src/scripts/pyolian/test_gen_class.template +++ b/src/scripts/pyolian/test_gen_class.template @@ -4,8 +4,10 @@ Class: ${cls.full_name}$ ================================================================================ Class type: ${cls.type}$ Base Class: ${cls.base_class.full_name if cls.base_class else None}$ -Inherits: ${list(cls.inherits)}$ -InheritsFull: ${cls.inherits_full}$ +Inherits: ${', '.join([i.full_name for i in cls.inherits])}$ +Hierarchy: ${' => '.join([i.full_name for i in cls.hierarchy])}$ +InheritsFull: ${', '.join([i.full_name for i in cls.inherits_full])}$ +Namespace: ${cls.namespace}$ Namespaces: ${list(cls.namespaces)}$ File: ${cls.file}$ Ctor enable: ${cls.ctor_enable}$ @@ -35,6 +37,14 @@ Properties: no properties available <!--(end)--> +Implements: +=========== +<!--(for i in cls.implements)--> + * ${i.full_name}$ +<!--(else)--> + no implements available +<!--(end)--> + Events: ======= <!--(for event in cls.events)--> --