コード例 #1
0
'''
output=out
'''
a=1
def f():
    return(a)

out = f()
print out
"""


def load_data():
    model = PythonModel(name='func')
    model.set_code(code)

    tmpdir = tempdir()

    data = PythonFile(content=code, path=tmpdir / "test.py")

    # ns is provided by tester
    editor = ns['editor_manager']
    editor.open_data(data)


if __name__ == '__main__':
    tests = [
        load_data
    ]
    test_applet('EditorManager', tests=tests)
コード例 #2
0
ファイル: test_world.py プロジェクト: gbaty/openalea
    obj2 = world["obj2"]

    obj1.set_attribute('a1', 1, 'IInt', constraints=c1)
    obj1.set_attribute('a2', True, 'IBool')
    obj2.set_attribute('b1', 2.34, 'IFloat', constraints=c2)


def add_objects_with_attributes_set():
    """
    Attributes are defined before adding object to world.
    Results is less signals sent by world
    """
    world = World()
    world.clear()
    obj1 = WorldObject("obj1", 1)
    obj2 = WorldObject("obj2", 2)

    obj1.set_attribute('a1', 1, 'IInt', constraints=c1)
    obj1.set_attribute('a2', True, 'IBool')
    obj2.set_attribute('b1', 2.34, 'IFloat', constraints=c2)

    world["obj1"] = obj1
    world["obj2"] = obj2


if __name__ == '__main__':
    test_applet('WorldControl', 'World', tests=[
        add_objects_with_attributes_set,
        add_objects_then_attributes
    ])
コード例 #3
0
    obj2 = world["obj2"]

    obj1.set_attribute('a1', 1, 'IInt', constraints=c1)
    obj1.set_attribute('a2', True, 'IBool')
    obj2.set_attribute('b1', 2.34, 'IFloat', constraints=c2)


def add_objects_with_attributes_set():
    """
    Attributes are defined before adding object to world.
    Results is less signals sent by world
    """
    world = World()
    world.clear()
    obj1 = WorldObject("obj1", 1)
    obj2 = WorldObject("obj2", 2)

    obj1.set_attribute('a1', 1, 'IInt', constraints=c1)
    obj1.set_attribute('a2', True, 'IBool')
    obj2.set_attribute('b1', 2.34, 'IFloat', constraints=c2)

    world["obj1"] = obj1
    world["obj2"] = obj2


if __name__ == '__main__':
    test_applet(
        'WorldControl',
        'World',
        tests=[add_objects_with_attributes_set, add_objects_then_attributes])
コード例 #4
0
        return [self.menu_edit, self.action_menu_1]

    def initialize(self):
        print "initialize", self


class TestAppletPlugin(object):
    name = 'TestApplet'
    label = 'Test Applet'

    def __call__(self):
        return TestApplet


from openalea.core.service.plugin import register_plugin, plugins
from openalea.core.util import camel_case_to_lower
register_plugin(TestAppletPlugin, 'oalab.applet')

if __name__ == '__main__':
    SAMPLE_WIDGET = 'FileBrowser'
    sample_widget = camel_case_to_lower(SAMPLE_WIDGET)

    def hello_world():
        print 'Hello OpenAleaLab world'

    def change_applet(applet_name='TestApplet'):
        widget = ns[sample_widget]
        widget.parent_tab.set_applet(applet_name)

    test_applet(SAMPLE_WIDGET, tests=[hello_world, change_applet])
コード例 #5
0
code = """
'''
output=out
'''
a=1
def f():
    return(a)

out = f()
print out
"""


def load_data():
    model = PythonModel(name='func')
    model.set_code(code)

    tmpdir = tempdir()

    data = PythonFile(content=code, path=tmpdir / "test.py")

    # ns is provided by tester
    editor = ns['editor_manager']
    editor.open_data(data)


if __name__ == '__main__':
    tests = [load_data]
    test_applet('EditorManager', tests=tests)
コード例 #6
0
ファイル: test_new_layout.py プロジェクト: gbaty/openalea
    def initialize(self):
        print "initialize", self


class TestAppletPlugin(object):
    name = "TestApplet"
    label = "Test Applet"

    def __call__(self):
        return TestApplet


from openalea.core.service.plugin import register_plugin, plugins
from openalea.core.util import camel_case_to_lower

register_plugin(TestAppletPlugin, "oalab.applet")

if __name__ == "__main__":
    SAMPLE_WIDGET = "FileBrowser"
    sample_widget = camel_case_to_lower(SAMPLE_WIDGET)

    def hello_world():
        print "Hello OpenAleaLab world"

    def change_applet(applet_name="TestApplet"):
        widget = ns[sample_widget]
        widget.parent_tab.set_applet(applet_name)

    test_applet(SAMPLE_WIDGET, tests=[hello_world, change_applet])