def setUp(self): self.tmpdir = tempdir() self.tmpdir2 = tempdir() pm.clear() # Force to ignore default repositories pm.repositories = [self.tmpdir] ev.events # clear events
def setUp(self): self.init() self.tmpdir = tempdir() self.model = PythonModel(name='func') self.model.set_code(SAMPLE_CODE) self.data = PythonFile(content=SAMPLE_CODE, path=self.tmpdir / "test.py")
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)
def install_package(): tmppath = tempdir() pythonpath = tmppath / 'lib' sys.path.insert(0, pythonpath) testpath = Path(__file__).parent.abspath() pythonpath.mkdir() sys.path.insert(0, pythonpath / 'tstpkg1-0.1-py2.7.egg') PYTHONPATH = os.environ.get('PYTHONPATH', None) if PYTHONPATH: PYTHONPATH = os.pathsep.join([pythonpath, PYTHONPATH]) else: PYTHONPATH = pythonpath os.environ['PYTHONPATH'] = PYTHONPATH oldcwd = os.getcwd() oldargs = list(sys.argv) os.chdir(testpath / 'tstdistrib') from setuptools import setup setup( name="tstpkg1", version="0.1", packages=['tstpkg1'], entry_points={ 'test.c1': [ 'Plugin1 = tstpkg1.plugin:C1Plugin1', 'Plugin2 = tstpkg1.plugin:C1Plugin2', ], 'test.c2': [ 'Plugin1 = tstpkg1.plugin:C2Plugin1', 'Plugin2 = tstpkg1.plugin:C2Plugin2', ], 'test.err1': ['Plugin = tstpkg1.plugin:C3PluginDoNotExist'], 'test.err2': ['Plugin = tstpkg1.plugin:C3PluginFailInstantiation'], 'test.err3': ['Plugin = tstpkg1.plugin:C3PluginFailCall'], 'test.err4': ['Plugin = tstpkg1.plugin:C3PluginClassFailInstantiation'], }, script_args=[ 'install', '--install-base=%s' % tmppath, '--install-purelib=%s' % pythonpath, '--install-platlib=%s' % pythonpath, '--install-scripts=%s' % (tmppath / 'bin'), '--install-headers=%s' % (tmppath / 'include'), '--install-data=%s' % (tmppath / 'share'), ] ) os.chdir(oldcwd) sys.argv = oldargs return tmppath, pythonpath
def install_package(): tmppath = tempdir() pythonpath = tmppath / 'lib' sys.path.insert(0, pythonpath) testpath = Path(__file__).parent.abspath() pythonpath.mkdir() sys.path.insert(0, pythonpath / 'tstpkg1-0.1-py2.7.egg') PYTHONPATH = os.environ.get('PYTHONPATH', None) if PYTHONPATH: PYTHONPATH = os.pathsep.join([pythonpath, PYTHONPATH]) else: PYTHONPATH = pythonpath os.environ['PYTHONPATH'] = PYTHONPATH oldcwd = os.getcwd() oldargs = list(sys.argv) os.chdir(testpath / 'tstdistrib') from setuptools import setup setup( name="tstpkg1", version="0.1", packages=['tstpkg1'], entry_points={ 'test.c1': [ 'Plugins = tstpkg1.plugin', ], 'test.c2': [ 'Plugin1 = tstpkg1.plugin:C2Plugin1', 'Plugin2 = tstpkg1.plugin:C2Plugin2', ], 'test.err1': ['Plugin = tstpkg1.plugin:C3PluginDoNotExist'], 'test.err2': ['Plugin = tstpkg1.plugin:C3PluginFailInstantiation'], 'test.err3': ['Plugin = tstpkg1.plugin:C3PluginFailCall'], 'test.err4': ['Plugin = tstpkg1.plugin:C3PluginClassFailInstantiation'], }, script_args=[ 'install', '--install-base=%s' % tmppath, '--install-purelib=%s' % pythonpath, '--install-platlib=%s' % pythonpath, '--install-scripts=%s' % (tmppath / 'bin'), '--install-headers=%s' % (tmppath / 'include'), '--install-data=%s' % (tmppath / 'share'), ] ) os.chdir(oldcwd) sys.argv = oldargs return tmppath, pythonpath
def __init__(self, item, parent=None): super(Preview, self).__init__(parent) self._tmp = tempdir() self.setContentsMargins(0, 0, 0, 0) html = html_header html += html_summary(item, icon_path=qicon_path(item, self._tmp)) html += html_footer self.setText(html) self.setReadOnly(True)
def install_package(): tmppath = tempdir() pythonpath = tmppath / "lib" sys.path.insert(0, pythonpath) testpath = Path(__file__).parent.abspath() pythonpath.mkdir() sys.path.insert(0, pythonpath / "tstpkg1-0.1-py2.7.egg") PYTHONPATH = os.environ.get("PYTHONPATH", None) if PYTHONPATH: PYTHONPATH = os.pathsep.join([pythonpath, PYTHONPATH]) else: PYTHONPATH = pythonpath os.environ["PYTHONPATH"] = PYTHONPATH oldcwd = os.getcwd() oldargs = list(sys.argv) os.chdir(testpath / "tstdistrib") from setuptools import setup setup( name="tstpkg1", version="0.1", packages=["tstpkg1"], entry_points={ "test.c1": ["Plugins = tstpkg1.plugin"], "test.c2": ["Plugin1 = tstpkg1.plugin:C2Plugin1", "Plugin2 = tstpkg1.plugin:C2Plugin2"], "test.err1": ["Plugin = tstpkg1.plugin:C3PluginDoNotExist"], "test.err2": ["Plugin = tstpkg1.plugin:C3PluginFailInstantiation"], "test.err3": ["Plugin = tstpkg1.plugin:C3PluginFailCall"], "test.err4": ["Plugin = tstpkg1.plugin:C3PluginClassFailInstantiation"], }, script_args=[ "install", "--install-base=%s" % tmppath, "--install-purelib=%s" % pythonpath, "--install-platlib=%s" % pythonpath, "--install-scripts=%s" % (tmppath / "bin"), "--install-headers=%s" % (tmppath / "include"), "--install-data=%s" % (tmppath / "share"), ], ) os.chdir(oldcwd) sys.argv = oldargs return tmppath, pythonpath
def test_load_save(self): c1 = Control('a', value=1, constraints=dict(min=1, max=2)) c2 = Control('a', 'IStr', 'salut') orig = [c1, c2] tmp = tempdir() saver = ControlSaver() saver.save(orig, tmp / 'control.py') loader = ControlLoader() controls = loader.load(tmp / 'control.py') tmp.rmtree() assert len(controls) == len(orig) for i in range(len(orig)): self.compare_controls(orig[i], controls[i])
def test_move_project(self): self.project.add("model", filename="1.py", content="blablabla") old_path = self.project.path tmpdir2 = tempdir() events = self.ev.events # clear events self.project.move(tmpdir2 / "test2") assert old_path.exists() is False assert self.project.path != old_path assert self.project.name == "test2" assert self.project.name == "test2" events = self.ev.events self.check_events(events, ['project_moved', 'project_changed']) old_dir = self.project.projectdir self.project.rename("test3") assert self.project.name == "test3" assert self.project.projectdir == old_dir events = self.ev.events self.check_events(events, ['project_moved', 'project_changed'])
def setUp(self): self.tmpdir = tempdir() self.project = Project(self.tmpdir / 'test', alias='test') self.ev = EventTracker() self.project.register_listener(self.ev)
from openalea.vpltk.qt import QtGui import random from openalea.oalab.gui.container import ParadigmContainer from openalea.core.service.data import DataFactory from openalea.core.path import path as Path from openalea.core.path import tempdir if __name__ == '__main__': tmp = tempdir() instance = QtGui.QApplication.instance() if instance is None: app = QtGui.QApplication([]) else: app = instance pmw = ParadigmContainer(None, None) def test(): model1 = DataFactory('data/model.py') pmw.open_data(model1) from openalea.oalab.shell import get_shell_class from openalea.core.service.ipython import interpreter as interpreter_ # Set interpreter interpreter = interpreter_() interpreter.user_ns['interp'] = interpreter interpreter.user_ns.update(locals())
def setUp(self): self.tmpdir = tempdir()
from openalea.vpltk.qt import QtGui import random from openalea.oalab.paradigm.container import ParadigmContainer from openalea.core.service.data import DataFactory from openalea.core.path import path as Path from openalea.core.path import tempdir if __name__ == '__main__': tmp = tempdir() instance = QtGui.QApplication.instance() if instance is None: app = QtGui.QApplication([]) else: app = instance pmw = ParadigmContainer(None, None) def test(): model1 = DataFactory('data/model.py') pmw.open_data(model1) from openalea.oalab.shell import get_shell_class from openalea.core.service.ipython import interpreter as interpreter_ # Set interpreter interpreter = interpreter_() interpreter.user_ns['interp'] = interpreter interpreter.user_ns.update(locals())