当前位置: 首页>>代码示例>>Python>>正文


Python Workbench.unregister方法代码示例

本文整理汇总了Python中enaml.workbench.api.Workbench.unregister方法的典型用法代码示例。如果您正苦于以下问题:Python Workbench.unregister方法的具体用法?Python Workbench.unregister怎么用?Python Workbench.unregister使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在enaml.workbench.api.Workbench的用法示例。


在下文中一共展示了Workbench.unregister方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: pulses_workbench

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import unregister [as 别名]
def pulses_workbench(monkeypatch, app_dir):
    """Setup the workbench in such a way that the pulses manager can be tested.

    """

    def exit_err(self):
        """Turn error reporting into an exception.

        """
        if self._delayed:
            raise Exception("Unexpected exceptions occured :\n" + pformat(self._delayed))

    monkeypatch.setattr(ErrorsPlugin, "exit_error_gathering", exit_err)
    workbench = Workbench()
    workbench.register(CoreManifest())
    workbench.register(AppManifest())
    workbench.register(PreferencesManifest())
    workbench.register(ErrorsManifest())
    workbench.register(StateManifest())
    workbench.register(DependenciesManifest())
    workbench.register(MeasureManifest())
    workbench.register(PulsesManagerManifest())

    yield workbench

    for m_id in ("ecpy.pulses", "ecpy.app.dependencies", "ecpy.app.errors", "ecpy.app.preferences", "ecpy.app"):
        try:
            workbench.unregister(m_id)
        except Exception:
            pass
开发者ID:Ecpy,项目名称:ecpy_pulses,代码行数:32,代码来源:fixtures.py

示例2: measure_workbench

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import unregister [as 别名]
def measure_workbench(monkeypatch, app_dir):
    """Setup the workbench in such a way that the measure plugin can be tested.

    """
    def exit_err(self):
        self._gathering_counter -= 1
        if self._gathering_counter < 1:
            self._gathering_counter = 0
            if self._delayed:
                msg = 'Unexpected exceptions occured :\n'
                raise ErrorDialogException(msg + pformat(self._delayed))

    monkeypatch.setattr(ErrorsPlugin, 'exit_error_gathering', exit_err)
    workbench = Workbench()
    workbench.register(CoreManifest())
    workbench.register(AppManifest())
    workbench.register(PreferencesManifest())
    workbench.register(ErrorsManifest())
    workbench.register(DependenciesManifest())
    workbench.register(StateManifest())
    workbench.register(MeasureManifest())

    yield workbench

    for m_id in ('ecpy.measure', 'ecpy.app.dependencies', 'ecpy.app.errors',
                 'ecpy.app.preferences', 'ecpy.app'):
        try:
            workbench.unregister(m_id)
        except ValueError:
            pass
开发者ID:PhilipVinc,项目名称:ecpy,代码行数:32,代码来源:fixtures.py

示例3: instr_workbench

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import unregister [as 别名]
def instr_workbench(monkeypatch, app_dir, app):
    """Setup the workbench in such a way that the instrs manager can be tested.

    """
    def exit_err(self):
        if self._delayed:
            raise Exception('Unexpected exceptions occured :\n' +
                            pformat(self._delayed))

    monkeypatch.setattr(ErrorsPlugin, 'exit_error_gathering', exit_err)
    workbench = Workbench()
    workbench.register(CoreManifest())
    workbench.register(AppManifest())
    workbench.register(PreferencesManifest())
    workbench.register(ErrorsManifest())
    workbench.register(StateManifest())
    workbench.register(DependenciesManifest())
    workbench.register(InstrumentManagerManifest())

    yield workbench

    for m_id in ('ecpy.instruments', 'ecpy.app.dependencies',
                 'ecpy.app.errors', 'ecpy.app.preferences',
                 'ecpy.app.states', 'ecpy.app'):
        try:
            workbench.unregister(m_id)
        except Exception:
            pass
开发者ID:PhilipVinc,项目名称:ecpy,代码行数:30,代码来源:fixtures.py

示例4: TestApplyMagFieldView

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import unregister [as 别名]
class TestApplyMagFieldView(object):

    def setup(self):
        self.workbench = Workbench()
        self.workbench.register(CoreManifest())
        self.workbench.register(StateManifest())
        self.workbench.register(PreferencesManifest())
        self.workbench.register(InstrManagerManifest())
        self.workbench.register(TaskManagerManifest())

        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = ApplyMagFieldTask(task_name='Test')
        self.root.children_task.append(self.task)
        self.root.run_time['drivers'] = {'Test': InstrHelper}

    def teardown(self):
        close_all_windows()

        self.workbench.unregister(u'hqc_meas.task_manager')
        self.workbench.unregister(u'hqc_meas.instr_manager')
        self.workbench.unregister(u'hqc_meas.preferences')
        self.workbench.unregister(u'hqc_meas.state')
        self.workbench.unregister(u'enaml.workbench.core')

    def test_view1(self):
        # Intantiate a view with no selected interface and select one after
        window = enaml.widgets.api.Window()
        core = self.workbench.get_plugin('enaml.workbench.core')
        view = ApplyMagFieldView(window, task=self.task, core=core)
        window.show()

        process_app_events()
开发者ID:MatthieuDartiailh,项目名称:HQCMeas,代码行数:34,代码来源:test_apply_mag_field_task.py

示例5: TestPNASetRFFrequencyView

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import unregister [as 别名]
class TestPNASetRFFrequencyView(object):

    def setup(self):
        self.workbench = Workbench()
        self.workbench.register(CoreManifest())
        self.workbench.register(StateManifest())
        self.workbench.register(PreferencesManifest())
        self.workbench.register(InstrManagerManifest())
        self.workbench.register(TaskManagerManifest())

        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = SetRFFrequencyTask(task_name='Test')
        self.root.children_task.append(self.task)
        self.root.run_time['drivers'] = {'Test': InstrHelper}

    def teardown(self):
        close_all_windows()

        self.workbench.unregister(u'hqc_meas.task_manager')
        self.workbench.unregister(u'hqc_meas.instr_manager')
        self.workbench.unregister(u'hqc_meas.preferences')
        self.workbench.unregister(u'hqc_meas.state')
        self.workbench.unregister(u'enaml.workbench.core')

    def test_view1(self):
        # Intantiate a view with no selected interface and select one after
        window = enaml.widgets.api.Window()
        core = self.workbench.get_plugin('enaml.workbench.core')
        view = RFFrequencyView(window, task=self.task, core=core)
        window.show()

        process_app_events()

        assert_in('AgilentPNA', view.drivers)
        self.task.selected_driver = 'AgilentPNA'
        process_app_events()
        assert_is_instance(self.task.interface, PNASetRFFrequencyInterface)

    def test_view2(self):
        # Intantiate a view with a selected interface.
        self.task.interface = PNASetRFFrequencyInterface(task=self.task)
        self.task.frequency = '1.0'
        self.task.selected_driver = 'AgilentPNA'

        interface = self.task.interface

        window = enaml.widgets.api.Window()
        core = self.workbench.get_plugin('enaml.workbench.core')
        RFFrequencyView(window, task=self.task, core=core)
        window.show()

        process_app_events()

        assert_is(self.task.interface, interface)
开发者ID:MatthieuDartiailh,项目名称:HQCMeas,代码行数:56,代码来源:test_pna_tasks.py

示例6: TestDefinitionView

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import unregister [as 别名]
class TestDefinitionView(object):

    def setup(self):
        self.workbench = Workbench()
        self.workbench.register(CoreManifest())
        self.workbench.register(StateManifest())
        self.workbench.register(PreferencesManifest())
        self.workbench.register(TaskManagerManifest())

        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = DefinitionTask(task_name='Test')
        self.root.children_task.append(self.task)

    def teardown(self):
        close_all_windows()

        self.workbench.unregister(u'hqc_meas.task_manager')
        self.workbench.unregister(u'hqc_meas.preferences')
        self.workbench.unregister(u'hqc_meas.state')
        self.workbench.unregister(u'enaml.workbench.core')

    def test_view(self):
        # Intantiate a view.
        window = enaml.widgets.api.Window()
        DefinitionView(window, task=self.task)
        window.show()

        process_app_events()

        self.task.definitions = [('1', '2.0'), ('2', "*['a', 1.0]")]

        process_app_events()
开发者ID:MatthieuDartiailh,项目名称:HQCMeas,代码行数:34,代码来源:test_def_task.py

示例7: TestWhileView

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import unregister [as 别名]
class TestWhileView(object):

    def setup(self):
        self.workbench = Workbench()
        self.workbench.register(CoreManifest())
        self.workbench.register(StateManifest())
        self.workbench.register(PreferencesManifest())
        self.workbench.register(TaskManagerManifest())

        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = WhileTask(task_name='Test', condition='rr')
        self.root.children_task.append(self.task)

    def teardown(self):
        close_all_windows()

        self.workbench.unregister(u'hqc_meas.task_manager')
        self.workbench.unregister(u'hqc_meas.preferences')
        self.workbench.unregister(u'hqc_meas.state')
        self.workbench.unregister(u'enaml.workbench.core')

    def test_view(self):
        # Intantiate a view with no selected interface and select one after
        window = enaml.widgets.api.Window()
        core = self.workbench.get_plugin('enaml.workbench.core')
        view = WhileView(window, task=self.task, core=core)
        window.show()

        process_app_events()

        assert_equal(view.widgets()[1].text, 'rr')

        view.widgets()[1].text = 'test'
        process_app_events()
        assert_equal(self.task.condition, 'test')
开发者ID:MatthieuDartiailh,项目名称:HQCMeas,代码行数:37,代码来源:test_while_task.py

示例8: dep_workbench

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import unregister [as 别名]
def dep_workbench():
    """Setup the workbench to test dependencies related capabilities.

    """
    workbench = Workbench()
    workbench.register(CoreManifest())
    workbench.register(DependenciesManifest())
    workbench.register(BuildDep())
    workbench.register(RuntimeDep())

    yield workbench

    workbench.unregister('ecpy.app.dependencies')
    workbench.unregister('enaml.workbench.core')
开发者ID:MatthieuDartiailh,项目名称:ecpy,代码行数:16,代码来源:test_plugin.py

示例9: TestSaveArrayView

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import unregister [as 别名]
class TestSaveArrayView(object):

    def setup(self):
        self.workbench = Workbench()
        self.workbench.register(CoreManifest())
        self.workbench.register(StateManifest())
        self.workbench.register(PreferencesManifest())
        self.workbench.register(TaskManagerManifest())

        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = SaveArrayTask(task_name='Test')
        self.root.children_task.append(self.task)

    def teardown(self):
        close_all_windows()

        self.workbench.unregister(u'hqc_meas.task_manager')
        self.workbench.unregister(u'hqc_meas.preferences')
        self.workbench.unregister(u'hqc_meas.state')
        self.workbench.unregister(u'enaml.workbench.core')

    def test_view(self):
        # Intantiate a view with no selected interface and select one after
        window = enaml.widgets.api.Window()
        view = SaveArrayView(window, task=self.task)
        window.show()

        process_app_events()
开发者ID:jf---,项目名称:HQCMeas,代码行数:30,代码来源:test_save_tasks.py

示例10: TestCollectingFromConfig

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import unregister [as 别名]
class TestCollectingFromConfig(object):
    """Test collecting dependencies from ConfigObj object.

    """

    def setup(self):

        self.workbench = Workbench()
        self.workbench.register(CoreManifest())
        self.workbench.register(DependenciesManifest())
        self.workbench.register(BuildDep())

    def teardown(self):
        self.workbench.unregister('ecpy.app.dependencies')
        self.workbench.unregister('enaml.workbench.core')

    def test_collecting(self):
        """Test collecting from a dict-like object.

        """
        core = self.workbench.get_plugin('enaml.workbench.core')
        res, dep = core.invoke_command(COLLECT,
                                       {'obj': ConfigObj({'val': '1',
                                                          'dep_type': 'test'})}
                                       )
        assert res
        assert dep.keys() == ['test']

    def test_handling_errors(self, monkeypatch):
        """Test handling errors occuring when collecting dependencies.

        """
        plugin = self.workbench.get_plugin('ecpy.app.dependencies')

        for b in plugin.build_deps.contributions.values():
            monkeypatch.setattr(b, 'err', True)

        core = self.workbench.get_plugin('enaml.workbench.core')
        res, dep = core.invoke_command(COLLECT,
                                       {'obj': ConfigObj({'val': '1',
                                                          'dep_type': 'test'})}
                                       )

        assert not res
        assert 'test' in dep
开发者ID:pombredanne,项目名称:ecpy,代码行数:47,代码来源:test_plugin.py

示例11: TestLoadArrayView

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import unregister [as 别名]
class TestLoadArrayView(object):

    def setup(self):
        self.workbench = Workbench()
        self.workbench.register(CoreManifest())
        self.workbench.register(StateManifest())
        self.workbench.register(PreferencesManifest())
        self.workbench.register(TaskManagerManifest())

        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = LoadArrayTask(task_name='Test')
        self.root.children_task.append(self.task)

    def teardown(self):
        close_all_windows()

        self.workbench.unregister(u'hqc_meas.task_manager')
        self.workbench.unregister(u'hqc_meas.preferences')
        self.workbench.unregister(u'hqc_meas.state')
        self.workbench.unregister(u'enaml.workbench.core')

    def test_view(self):
        # Intantiate a view with no selected interface and select one after
        window = enaml.widgets.api.Window()
        core = self.workbench.get_plugin('enaml.workbench.core')
        view = LoadArrayView(window, task=self.task, core=core)
        window.show()

        process_app_events()

        assert_is(self.task.interface, None)

        assert_in('CSV', view.file_formats)
        self.task.selected_format = 'CSV'
        process_app_events()
        assert_is_instance(self.task.interface,
                           CSVLoadInterface)

    def test_view2(self):
        # Intantiate a view with a selected interface.
        interface = CSVLoadInterface()
        self.task.interface = interface
        self.task.selected_format = 'CSV'

        interface = self.task.interface

        window = enaml.widgets.api.Window()
        core = self.workbench.get_plugin('enaml.workbench.core')
        LoadArrayView(window, task=self.task, core=core)
        window.show()

        process_app_events()

        assert_is(self.task.interface, interface)
开发者ID:MatthieuDartiailh,项目名称:HQCMeas,代码行数:56,代码来源:test_load_tasks.py

示例12: TestLogPlugin

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import unregister [as 别名]
class TestLogPlugin(object):
    """Test all the commands deined by the LogPLugin.

    """
    def setup(self):
        self.workbench = Workbench()
        self.workbench.register(CoreManifest())
        self.workbench.register(AppManifest())
        self.workbench.register(PreferencesManifest())
        self.workbench.register(StateManifest())
        self.workbench.register(LogManifest())

    def teardown(self):
        self.workbench.unregister(PLUGIN_ID)

    def test_handler1(self, logger):
        """Test adding removing handler.

        """
        core = self.workbench.get_plugin(u'enaml.workbench.core')
        handler = GuiHandler(model=LogModel())
        core.invoke_command('ecpy.app.logging.add_handler',
                            {'id': 'ui', 'handler': handler, 'logger': 'test'},
                            self)
        log_plugin = self.workbench.get_plugin(PLUGIN_ID)

        assert log_plugin.handler_ids == ['ui']
        assert handler in logger.handlers
        assert log_plugin._handlers == {'ui': (handler, 'test')}

        core.invoke_command('ecpy.app.logging.remove_handler',
                            {'id': 'ui'}, self)

        assert log_plugin.handler_ids == []
        assert handler not in logger.handlers
        assert log_plugin._handlers == {}

    def test_handler2(self, logger):
        """Test adding a GUI handler using the mode keyword.

        """
        core = self.workbench.get_plugin(u'enaml.workbench.core')
        core.invoke_command('ecpy.app.logging.add_handler',
                            {'id': 'ui', 'mode': 'ui', 'logger': 'test'},
                            self)
        log_plugin = self.workbench.get_plugin(PLUGIN_ID)

        assert log_plugin.handler_ids == [u'ui']
        assert logger.handlers

        core.invoke_command('ecpy.app.logging.remove_handler',
                            {'id': 'ui'}, self)

        assert log_plugin.handler_ids == []
        assert not logger.handlers

    def test_handler3(self, logger):
        """Test adding an handler using a non recognised mode.

        """
        core = self.workbench.get_plugin(u'enaml.workbench.core')
        core.invoke_command('ecpy.app.logging.add_handler',
                            {'id': 'ui', 'logger': 'test'},
                            self)
        log_plugin = self.workbench.get_plugin(PLUGIN_ID)

        assert log_plugin.handler_ids == []
        assert not logger.handlers

    def test_filter1(self, logger):
        """Test adding removing filter.

        """
        core = self.workbench.get_plugin(u'enaml.workbench.core')
        handler = GuiHandler(model=LogModel())
        core.invoke_command('ecpy.app.logging.add_handler',
                            {'id': 'ui', 'handler': handler, 'logger': 'test'},
                            self)

        class Filter(object):

            def filter(self, record):
                return True

        test_filter = Filter()

        core.invoke_command('ecpy.app.logging.add_filter',
                            {'id': 'filter', 'filter': test_filter,
                             'handler_id': 'ui'},
                            self)

        log_plugin = self.workbench.get_plugin(PLUGIN_ID)

        assert log_plugin.filter_ids == [u'filter']
        assert log_plugin._filters == {u'filter': (test_filter, u'ui')}

        core.invoke_command('ecpy.app.logging.remove_filter',
                            {'id': 'filter'}, self)

        assert log_plugin.filter_ids == []
#.........这里部分代码省略.........
开发者ID:PhilipVinc,项目名称:ecpy,代码行数:103,代码来源:test_plugin.py

示例13: Test_State

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import unregister [as 别名]
class Test_State(object):

    @classmethod
    def setup_class(cls):
        print complete_line(__name__ +
                            ':{}.setup_class()'.format(cls.__name__), '-', 77)

    @classmethod
    def teardown_class(cls):
        print complete_line(__name__ +
                            ':{}.teardown_class()'.format(cls.__name__), '-',
                            77)

    def setup(self):
        self.workbench = Workbench()
        self.workbench.register(CoreManifest())
        self.workbench.register(StateManifest())
        self.workbench.register(StateContributor())

    def teardown(self):
        pass

    def test_get_state(self):
        core = self.workbench.get_plugin(CORE_PLUGIN)
        par = {'state_id': 'test.states.state'}
        assert core.invoke_command(GET_STATE,
                                   par, trigger=self)

    def test_state_content(self):
        core = self.workbench.get_plugin(CORE_PLUGIN)
        par = {'state_id': 'test.states.state'}
        state = core.invoke_command(GET_STATE,
                                    par, trigger=self)
        assert_true(hasattr(state, 'string'))
        assert_equal(state.string, 'init')
        assert_true(hasattr(state, 'prop'))

    def test_member_sync(self):
        core = self.workbench.get_plugin(CORE_PLUGIN)
        par = {'state_id': 'test.states.state'}
        state = core.invoke_command(GET_STATE,
                                    par, trigger=self)

        plugin = self.workbench.get_plugin('test.states')
        plugin.string = 'test'

        assert_equal(state.string, 'test')

    def test_prop_getter(self):
        core = self.workbench.get_plugin(CORE_PLUGIN)
        par = {'state_id': 'test.states.state'}
        state = core.invoke_command(GET_STATE,
                                    par, trigger=self)

        assert_equal(state.prop, 'ok')

    def test_death_notif1(self):
        core = self.workbench.get_plugin(CORE_PLUGIN)
        par = {'state_id': 'test.states.state'}
        state = core.invoke_command(GET_STATE,
                                    par, trigger=self)

        self.workbench.unregister(u'test.states')
        assert_is(state.alive, False)

    def test_death_notif2(self):
        self.workbench.register(StateContributor2())
        core = self.workbench.get_plugin(CORE_PLUGIN)
        par = {'state_id': 'test.states.state2'}
        state = core.invoke_command(GET_STATE,
                                    par, trigger=self)

        self.workbench.unregister(u'test.states2')
        assert_is(state.alive, False)
开发者ID:PhilipVinc,项目名称:HQCMeas,代码行数:76,代码来源:test_states.py

示例14: TestExtensionsCollector

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import unregister [as 别名]
class TestExtensionsCollector(object):
    """Test the ExtensionsCollector behaviour.

    """
    def setup(self):
        self.workbench = Workbench()
        self.workbench.register(CoreManifest())
        self.workbench.register(ErrorsManifest())
        self.workbench.register(ExtensionManifest())

    def test_registation1(self, windows):
        """Test that plugin registered before starting the plugin are well
        detected

        """
        c = Contributor1()
        self.workbench.register(c)
        plugin = self.workbench.get_plugin(PLUGIN_ID)

        assert 'contrib1.contrib' in plugin.contribs.contributions

        self.workbench.unregister(c.id)

        assert 'contrib1.contrib' not in plugin.contribs.contributions
        assert not plugin.contribs._extensions

        plugin.contribs.stop()
        assert not plugin.contribs.contributions

    def test_registration2(self, windows):
        """Test contribs update when a new plugin is registered.

        """
        self.workbench.register(Contributor2())
        plugin = self.workbench.get_plugin(PLUGIN_ID)
        c = Contributor1()
        self.workbench.register(c)

        assert 'contrib1.contrib' in plugin.contribs.contributions

        self.workbench.unregister(c.id)

        assert 'contrib1.contrib' not in plugin.contribs.contributions

    def test_factory(self, windows):
        """Test getting the Contribution declaration from a factory.

        """
        c = Contributor2()
        self.workbench.register(c)
        plugin = self.workbench.get_plugin(PLUGIN_ID)

        assert 'contrib2.contrib' in plugin.contribs.contributions

        self.workbench.unregister(c.id)

        assert 'contrib2.contrib' not in plugin.contribs.contributions

    @pytest.mark.ui
    def test_errors1(self, windows):
        """Test uniqueness of contribution id.

        """

        self.workbench.register(Contributor1())
        self.workbench.register(Contributor1(id='bis'))
        self.workbench.register(Contributor1(id='ter'))
        with handle_dialog():
            self.workbench.get_plugin(PLUGIN_ID)

    @pytest.mark.ui
    def test_check_errors2(self, windows):
        """Test use of validate_ext.

        """

        self.workbench.register(Contributor3())
        with handle_dialog():
            self.workbench.get_plugin(PLUGIN_ID)

    def test_check_errors3(self, windows):
        """Test enforcement of type when using factory.

        """

        self.workbench.register(Contributor4())
        with handle_dialog():
            self.workbench.get_plugin(PLUGIN_ID)

    def test_declared_by(self):
        """Test getting the extension declaring a particular contribution.

        """
        c = Contributor1()
        self.workbench.register(c)
        plugin = self.workbench.get_plugin(PLUGIN_ID)

        assert plugin.contribs.contributed_by('contrib1.contrib') is \
            c.extensions[0]
开发者ID:pombredanne,项目名称:ecpy,代码行数:101,代码来源:test_plugin_tools.py

示例15: TestPreferencesPlugin

# 需要导入模块: from enaml.workbench.api import Workbench [as 别名]
# 或者: from enaml.workbench.api.Workbench import unregister [as 别名]

#.........这里部分代码省略.........
        class DummyArgs(object):

            reset_app_folder = True

        with handle_dialog(custom=lambda x: setattr(x, 'path', app_dir)):
            app.run_app_startup(DummyArgs)

        assert os.path.isfile(app_pref)
        assert ConfigObj(app_pref)['app_path'] == app_dir
        assert os.path.isdir(app_dir)

    def test_lifecycle(self, app_dir):
        """Test the plugin lifecycle when no default.ini exist in app folder.

        """
        pref_man = PreferencesManifest()
        self.workbench.register(pref_man)
        c_man = PrefContributor()
        self.workbench.register(c_man)

        # Start preferences plugin.
        prefs = self.workbench.get_plugin(PLUGIN_ID)
        assert prefs.app_directory == app_dir
        assert os.path.isdir(os.path.join(app_dir, 'preferences'))
        core = self.workbench.get_plugin('enaml.workbench.core')
        assert core.invoke_command('ecpy.app.preferences.get',
                                   dict(plugin_id='test.prefs')) is not None

        self.workbench.register(PrefContributor2())
        assert core.invoke_command('ecpy.app.preferences.get',
                                   dict(plugin_id='test.prefs2')) is not None

        # Stopping
        self.workbench.unregister(c_man.id)
        with pytest.raises(KeyError):
            core.invoke_command('ecpy.app.preferences.get',
                                dict(plugin_id='test.prefs'))
        self.workbench.unregister(pref_man.id)
        assert not prefs._prefs
        assert not prefs._pref_decls

    def test_load_defaultini(self, app_dir):
        """Test that a default.ini file found in the app folder under prefs
        is loaded on startup.

        """
        prefs_path = os.path.join(app_dir, 'preferences')
        os.mkdir(os.path.join(app_dir, 'preferences'))

        conf = ConfigObj(os.path.join(prefs_path, 'default.ini'))
        c_man = PrefContributor()
        conf[c_man.id] = {}
        conf[c_man.id]['string'] = 'This is a test'
        conf.write()

        pref_man = PreferencesManifest()
        self.workbench.register(pref_man)
        self.workbench.register(c_man)

        c_pl = self.workbench.get_plugin(c_man.id)

        assert c_pl.string == 'This is a test'

    def test_update_contrib_and_type_checking(self, app_dir):
        """Check that the contributions are correctly updated when a new
        plugin is registered and check that the contribution is of the right
开发者ID:PhilipVinc,项目名称:ecpy,代码行数:70,代码来源:test_prefs.py


注:本文中的enaml.workbench.api.Workbench.unregister方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。