本文整理汇总了Python中gaphor.UML类的典型用法代码示例。如果您正苦于以下问题:Python UML类的具体用法?Python UML怎么用?Python UML使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UML类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_parse_operation
def test_parse_operation(self):
"""Test parsing simple operation
"""
o = factory.create(UML.Operation)
UML.parse(o, "myfunc()")
self.assertEqual("myfunc", o.name)
self.assertTrue(not o.returnResult[0].typeValue)
self.assertFalse(o.formalParameter)
示例2: test_parse_operation_return
def test_parse_operation_return(self):
"""Test parsing operation with return value
"""
o = factory.create(UML.Operation)
UML.parse(o, "+ myfunc(): int")
self.assertEqual("myfunc", o.name)
self.assertEqual("int", o.returnResult[0].typeValue)
self.assertEqual("public", o.visibility)
self.assertTrue(not o.formalParameter)
示例3: test_parse_property_simple
def test_parse_property_simple(self):
"""Test simple property parsing
"""
a = factory.create(UML.Property)
UML.parse(a, "myattr")
self.assertFalse(a.isDerived)
self.assertEqual("myattr", a.name)
self.assertTrue(a.typeValue is None, a.typeValue)
self.assertTrue(a.lowerValue is None, a.lowerValue)
self.assertTrue(a.upperValue is None, a.upperValue)
self.assertTrue(a.defaultValue is None, a.defaultValue)
示例4: test_parse_multiplicity
def test_parse_multiplicity(self):
"""Test parsing of multiplicity
"""
a = factory.create(UML.Association)
p = factory.create(UML.Property)
p.association = a
UML.parse(p, "0..2 { tag }")
self.assertTrue(p.name is None)
self.assertTrue(not p.typeValue)
self.assertEquals("0", p.lowerValue.value)
self.assertEquals("2", p.upperValue.value)
self.assertTrue(not p.defaultValue)
示例5: test_parse_operation_1_param
def test_parse_operation_1_param(self):
"""Test parsing of operation with one parameter
"""
o = factory.create(UML.Operation)
UML.parse(o, "- myfunc2 (a: node): double")
self.assertEqual("myfunc2", o.name)
self.assertEqual("double", o.returnResult[0].typeValue)
self.assertEqual("private", o.visibility)
self.assertEqual(1, len(o.formalParameter))
self.assertEqual("a", o.formalParameter[0].name)
self.assertEqual("node", o.formalParameter[0].typeValue)
self.assertTrue(o.formalParameter[0].defaultValue is None)
示例6: test_parse_multiplicity2
def test_parse_multiplicity2(self):
"""Test parsing of multiplicity with multiline constraints
"""
a = factory.create(UML.Association)
p = factory.create(UML.Property)
p.association = a
UML.parse(p, "0..2 { tag1, \ntag2}")
self.assertTrue(p.name is None)
self.assertTrue(not p.typeValue)
self.assertEqual("0", p.lowerValue)
self.assertEqual("2", p.upperValue)
self.assertTrue(not p.defaultValue)
示例7: _set_object_value
def _set_object_value(self, row, col, value):
attr = row[-1]
if col == 0:
UML.parse(attr, value)
row[0] = UML.format(attr)
elif col == 1:
attr.isStatic = not attr.isStatic
row[1] = attr.isStatic
elif col == 2:
# Value in attribute object changed:
row[0] = UML.format(attr)
row[1] = attr.isStatic
示例8: test_parse_property_invalid
def test_parse_property_invalid(self):
"""Test parsing property with invalid syntax
"""
a = factory.create(UML.Property)
UML.parse(a, '+ name = str[*] = "aap" { static }')
self.assertEqual('+ name = str[*] = "aap" { static }', a.name)
self.assertFalse(a.isDerived)
self.assertTrue(not a.typeValue)
self.assertTrue(not a.lowerValue)
self.assertTrue(not a.upperValue)
self.assertTrue(not a.defaultValue)
示例9: test_operation_parameter_deletion
def test_operation_parameter_deletion(self):
factory = UML.ElementFactory()
self.assertEquals(0, len(factory.lselect()))
c = factory.create(UML.Class)
c.name = 'Class'
o = factory.create(UML.Operation)
c.ownedOperation = o
UML.parse(o, 'a(x: int, y: int)')
c.unlink()
self.assertEquals(0, len(factory.lselect()), factory.lselect())
示例10: test_parse_property_complex
def test_parse_property_complex(self):
"""Test complex property parsing
"""
a = factory.create(UML.Property)
UML.parse(a, '+ / name : str[0..*] = "aap" { static }')
self.assertEqual("public", a.visibility)
self.assertTrue(a.isDerived)
self.assertEqual("name", a.name)
self.assertEqual("str", a.typeValue)
self.assertEqual("0", a.lowerValue)
self.assertEqual("*", a.upperValue)
self.assertEqual('"aap"', a.defaultValue)
示例11: test_parse_association_end
def test_parse_association_end(self):
"""Test parsing of association end
"""
a = factory.create(UML.Association)
p = factory.create(UML.Property)
p.association = a
UML.parse(p, "end")
self.assertEqual("end", p.name)
self.assertTrue(not p.typeValue)
self.assertTrue(not p.lowerValue)
self.assertTrue(not p.upperValue)
self.assertTrue(not p.defaultValue)
示例12: test_parse_derived_end
def test_parse_derived_end(self):
"""Test parsing derived association end
"""
a = factory.create(UML.Association)
p = factory.create(UML.Property)
p.association = a
UML.parse(p, "-/end[*] { mytag}")
self.assertEqual("private", p.visibility)
self.assertTrue(p.isDerived)
self.assertEqual("end", p.name)
self.assertTrue(not p.typeValue)
self.assertTrue(not p.lowerValue)
self.assertEqual("*", p.upperValue)
self.assertTrue(not p.defaultValue)
示例13: test_parse_operation_2_params
def test_parse_operation_2_params(self):
"""Test parsing of operation with two parameters
"""
o = factory.create(UML.Operation)
UML.parse(o, "# myfunc2 (a: str, b: int = 3 { static}): float")
self.assertEqual("myfunc2", o.name)
self.assertEqual("float", o.returnResult[0].typeValue)
self.assertEqual("protected", o.visibility)
self.assertEqual(2, len(o.formalParameter))
self.assertEqual("a", o.formalParameter[0].name)
self.assertEqual("str", o.formalParameter[0].typeValue)
self.assertTrue(o.formalParameter[0].defaultValue is None)
self.assertEqual("b", o.formalParameter[1].name)
self.assertEqual("int", o.formalParameter[1].typeValue)
self.assertEqual("3", o.formalParameter[1].defaultValue)
示例14: test_parse_operation_2_params
def test_parse_operation_2_params(self):
"""Test parsing of operation with two parameters
"""
o = factory.create(UML.Operation)
UML.parse(o, '# myfunc2 (a: str, b: int = 3 { static}): float')
self.assertEquals('myfunc2', o.name)
self.assertEquals('float', o.returnResult[0].typeValue)
self.assertEquals('protected', o.visibility)
self.assertEquals(2, len(o.formalParameter))
self.assertEquals('a', o.formalParameter[0].name)
self.assertEquals('str', o.formalParameter[0].typeValue)
self.assertTrue(o.formalParameter[0].defaultValue is None)
self.assertEquals('b', o.formalParameter[1].name)
self.assertEquals('int', o.formalParameter[1].typeValue)
self.assertEquals('3', o.formalParameter[1].defaultValue)
示例15: render
def render(self):
"""Render the OperationItem."""
return UML.format(self.subject,\
visibility=True,\
type=True,\
multiplicity=True,\
default=True) or ''