diff --git a/gaphor/misc/gidlethread.py b/gaphor/misc/gidlethread.py index 6018d3977..142e7e91b 100644 --- a/gaphor/misc/gidlethread.py +++ b/gaphor/misc/gidlethread.py @@ -1,6 +1,6 @@ # vim:sw=4:et: """This module contains some helpers that can be used to execute generator -functions in the GObject main loop. +functions in the GLib main loop. This module provided the following classes: GIdleThread - Thread like behavior for generators in a main loop @@ -18,7 +18,7 @@ from builtins import next from builtins import range import types import sys -from gi.repository import GLib, GObject +from gi.repository import GLib import time import traceback @@ -86,7 +86,7 @@ class GIdleThread(object): """Force the generator to stop running. """ if self.is_alive(): - GObject.source_remove(self._idle_id) + GLib.source_remove(self._idle_id) self._idle_id = 0 def is_alive(self): diff --git a/tests/test_gen_uml.py b/tests/test_gen_uml.py index fe32e9f65..ed50d9251 100644 --- a/tests/test_gen_uml.py +++ b/tests/test_gen_uml.py @@ -36,26 +36,26 @@ class GenUmlTestCase(unittest.TestCase): GENERATED = """# This file is generated by build_uml.py. DO NOT EDIT! -from properties import association, attribute, enumeration, derived, derivedunion, redefine +from gaphor.UML.properties import association, attribute, enumeration, derived, derivedunion, redefine # class 'ValSpec' has been stereotyped as 'SimpleAttribute' # class 'ShouldNotShowUp' has been stereotyped as 'SimpleAttribute' too -class C(object): pass -class D(C): pass class Element(object): pass class SubClass(Element): pass -C.attr = attribute('attr', 8cb780ba-3f11-11de-9595-00224128e79d, default=8cb7fd1a-3f11-11de-9595-00224128e79d, upper=8cb7df60-3f11-11de-9595-00224128e79d, lower=8cb7c11a-3f11-11de-9595-00224128e79d) -# 'SubClass.value' is a simple attribute -SubClass.value = attribute('value', str, lower=f9124094-3f14-11de-9595-00224128e79d) +class C(object): pass +class D(C): pass +C.attr = attribute('attr', 8cb780ba-3f11-11de-9595-00224128e79d, default=8cb7fd1a-3f11-11de-9595-00224128e79d, lower=8cb7c11a-3f11-11de-9595-00224128e79d, upper=8cb7df60-3f11-11de-9595-00224128e79d) C.name1 = association('name1', SubClass, lower=602cb072-3bcb-11de-ac7f-00224128e79d, opposite='name2') SubClass.name2 = association('name2', C, lower=602d56c6-3bcb-11de-ac7f-00224128e79d, opposite='name1') C.base = association('base', SubClass, lower=e053585e-3bcc-11de-aa0c-00224128e79d, opposite='abstract') -D.name3 = association('name3', SubClass, lower=1af287dc-3bcd-11de-aa0c-00224128e79d, opposite='name4') D.subbase = association('subbase', SubClass, lower=f8d56502-3bcc-11de-aa0c-00224128e79d, opposite='concrete') SubClass.concrete = association('concrete', D, lower=f8d5c998-3bcc-11de-aa0c-00224128e79d, upper=1665b18a-3bcd-11de-aa0c-00224128e79d, opposite='subbase') +D.name3 = association('name3', SubClass, lower=1af287dc-3bcd-11de-aa0c-00224128e79d, opposite='name4') SubClass.abstract = derivedunion('abstract', C, e053abd8-3bcc-11de-aa0c-00224128e79d, f48f64a2-3bcc-11de-aa0c-00224128e79d, SubClass.concrete) SubClass.name4 = redefine(SubClass, 'name4', D, name2) """ +# # 'SubClass.value' is a simple attribute +# SubClass.value = attribute('value', str, lower=f9124094-3f14-11de-9595-00224128e79d) # vim:sw=4:et:ai diff --git a/tests/test_issue_132.py b/tests/test_issue_132.py index 18d079cd1..d2bb794fa 100644 --- a/tests/test_issue_132.py +++ b/tests/test_issue_132.py @@ -38,6 +38,7 @@ class UndoRedoBugTestCase(TestCase): self.remove_attribute() assert len(self.class_.ownedAttribute) == 0 assert self.attribute.namespace is None + assert self.undo_manager.can_undo() self.undo_manager.undo_transaction() diff --git a/tests/test_issue_4.py b/tests/test_issue_4.py index 0dd0ac8b2..09be55874 100644 --- a/tests/test_issue_4.py +++ b/tests/test_issue_4.py @@ -5,7 +5,7 @@ Test GitHub issue #4. Diagram could not be loaded due to JuggleError import os import pkg_resources -from gi.repository import GObject +from gi.repository import GLib from gi.repository import Gtk from gaphor.storage.storage import load @@ -45,7 +45,7 @@ class CyclicDiagramTestCase(TestCase): finally: Gtk.main_quit() - assert GObject.timeout_add(1, handler) > 0 + assert GLib.timeout_add(1, handler) > 0 Gtk.main() diff --git a/tests/test_undo.py b/tests/test_undo.py index ad3208c7a..c87086d1f 100644 --- a/tests/test_undo.py +++ b/tests/test_undo.py @@ -13,11 +13,13 @@ class UndoTest(TestCase): factory = self.element_factory undo_manager = self.get_service('undo_manager') + self.assertEqual(0, len(self.diagram.canvas.solver.constraints)) + ci1 = self.create(items.ClassItem, UML.Class) - self.assertEqual(6, len(self.diagram.canvas.solver.constraints)) + self.assertEqual(2, len(self.diagram.canvas.solver.constraints)) ci2 = self.create(items.ClassItem, UML.Class) - self.assertEqual(12, len(self.diagram.canvas.solver.constraints)) + self.assertEqual(4, len(self.diagram.canvas.solver.constraints)) a = self.create(items.AssociationItem) @@ -26,7 +28,7 @@ class UndoTest(TestCase): # Diagram, Association, 2x Class, Property, LiteralSpecification self.assertEqual(6, len(factory.lselect())) - self.assertEqual(14, len(self.diagram.canvas.solver.constraints)) + self.assertEqual(6, len(self.diagram.canvas.solver.constraints)) @transactional def delete_class(): @@ -46,11 +48,11 @@ class UndoTest(TestCase): # Diagram, Class #self.assertEqual(2, len(factory.lselect()), factory.lselect()) - self.assertEqual(7, len(self.diagram.canvas.solver.constraints)) + self.assertEqual(3, len(self.diagram.canvas.solver.constraints)) undo_manager.undo_transaction() - self.assertEqual(14, len(self.diagram.canvas.solver.constraints)) + self.assertEqual(6, len(self.diagram.canvas.solver.constraints)) self.assertEqual(ci1, self.get_connected(a.head)) self.assertEqual(ci2, self.get_connected(a.tail)) diff --git a/utils/command/gen_uml.py b/utils/command/gen_uml.py index 8f6cf713e..f5c2679ec 100644 --- a/utils/command/gen_uml.py +++ b/utils/command/gen_uml.py @@ -13,10 +13,10 @@ # # Gaphor is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License +# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License # more details. # -# You should have received a copy of the GNU Library General Public +# You should have received a copy of the GNU Library General Public # along with Gaphor. If not, see . """ This file provides the code generator which transforms gaphor/UML/uml2.gaphor @@ -194,7 +194,7 @@ class Writer(object): def write_association(self, head, tail): """ - Write an association for head. + Write an association for head. The association should not be a redefine or derived association. """ if head.written: @@ -280,18 +280,18 @@ def parse_association_tags(appliedStereotypes): for stereotype in appliedStereotypes or []: for slot in stereotype.slot or []: - - #msg('scanning %s = %s' % (slot.definingFeature.name, slot.value.value)) + + msg('scanning %s = %s' % (slot.definingFeature.name, slot.value.value)) if slot.definingFeature.name == 'subsets': - value = slot.value + value = slot.value.value # remove all whitespaces and stuff value = value.replace(' ', '').replace('\n', '').replace('\r', '') subsets = value.split(',') if slot.definingFeature.name == 'redefines': - value = slot.value + value = slot.value.value # remove all whitespaces and stuff redefines = value.replace(' ', '').replace('\n', '').replace('\r', '') @@ -471,7 +471,7 @@ def generate(filename, outfile=None, overridesfile=None): ignored_classes.add(c) else: writer.write_classdef(c) - + # create attributes and enumerations derivedattributes = { } for c in [c for c in list(classes.values()) if c not in ignored_classes]: