Exemple #1
0
def test_running_main_error_in_parser_modifying(windows, monkeypatch):
    """Test starting the main app but encountering an issue while adding
    arguments.

    """
    import ecpy.__main__ as em

    def false_iter(arg):

        class FalseEntryPoint(EntryPoint):
            def load(self, *args, **kwargs):

                def false_modifier(parser):
                    raise Exception('Failed to add stupid argument to parser')

                return (false_modifier, 1)

        return [FalseEntryPoint('dummy', 'dummy')]

    monkeypatch.setattr(em, 'iter_entry_points', false_iter)

    def check_dialog(dial):
        assert 'modifying' in dial.text

    with pytest.raises(SystemExit):
        with handle_dialog('reject', check_dialog):
            main([])
Exemple #2
0
def test_running_main_error_in_parser_modifying(windows, monkeypatch):
    """Test starting the main app but encountering an issue while adding
    arguments.

    """
    import ecpy.__main__ as em

    def false_iter(arg):
        class FalseEntryPoint(EntryPoint):
            def load(self, *args, **kwargs):
                def false_modifier(parser):
                    raise Exception('Failed to add stupid argument to parser')

                return (false_modifier, 1)

        return [FalseEntryPoint('dummy', 'dummy')]

    monkeypatch.setattr(em, 'iter_entry_points', false_iter)

    def check_dialog(dial):
        assert 'modifying' in dial.text

    with pytest.raises(SystemExit):
        with handle_dialog('reject', check_dialog):
            main([])
Exemple #3
0
def test_running_main_asking_for_help(app):
    """Test starting the main app and closing it.

    """
    try:
        main(['-h'])
        # TODO make sure no window was opened ?
    except SystemExit as e:
        assert e.args == (0,)
Exemple #4
0
def test_running_main_asking_for_help(app):
    """Test starting the main app and closing it.

    """
    try:
        main(['-h'])
        # TODO make sure no window was opened ?
    except SystemExit as e:
        assert e.args == (0, )
Exemple #5
0
def test_running_main_error_in_parsing(windows):
    """Test starting the main app but encountering an issue while adding
    arguments.

    """
    def check_dialog(dial):
        assert 'cmd' in dial.text

    with pytest.raises(SystemExit):
        with handle_dialog('reject', check_dialog):
            main(['dummy'])
Exemple #6
0
def test_running_main_error_in_parsing(windows):
    """Test starting the main app but encountering an issue while adding
    arguments.

    """
    def check_dialog(dial):
        assert 'cmd' in dial.text

    with pytest.raises(SystemExit):
        with handle_dialog('reject', check_dialog):
            main(['dummy'])
Exemple #7
0
def test_running_main(app, app_dir, windows, monkeypatch):
    """Test starting the main app and closing it.

    """
    from enaml.workbench.ui.ui_plugin import UIPlugin

    def wait_for_window(self):
        pass

    # Do not release the application
    def no_release(self):
        pass

    monkeypatch.setattr(UIPlugin, '_release_application', no_release)
    monkeypatch.setattr(UIPlugin, 'start_application', wait_for_window)
    main([])
def test_running_main(app, app_dir, windows, monkeypatch):
    """Test starting the main app and closing it.

    """
    from enaml.workbench.ui.ui_plugin import UIPlugin

    def wait_for_window(self):
        pass

    # Do not release the application
    def no_release(self):
        pass

    monkeypatch.setattr(UIPlugin, '_release_application', no_release)
    monkeypatch.setattr(UIPlugin, 'start_application', wait_for_window)
    main([])
Exemple #9
0
def test_running_main_error_in_app_startup(windows, monkeypatch):
    """Test starting the main app but encountering an issue when running
    startups.

    """
    from ecpy.app.app_plugin import AppPlugin

    def false_run_startup(self, args):
        raise Exception('Fail to run start up')

    monkeypatch.setattr(AppPlugin, 'run_app_startup', false_run_startup)

    def check_dialog(dial):
        assert 'starting' in dial.text

    with pytest.raises(SystemExit):
        with handle_dialog('reject', check_dialog):
            main([])
Exemple #10
0
def test_running_main_error_in_app_startup(windows, monkeypatch):
    """Test starting the main app but encountering an issue when running
    startups.

    """
    from ecpy.app.app_plugin import AppPlugin

    def false_run_startup(self, args):
        raise Exception('Fail to run start up')

    monkeypatch.setattr(AppPlugin, 'run_app_startup', false_run_startup)

    def check_dialog(dial):
        assert 'starting' in dial.text

    with pytest.raises(SystemExit):
        with handle_dialog('reject', check_dialog):
            main([])
Exemple #11
0
def test_running_main_error_in_loading(windows, monkeypatch):
    """Test starting the main app but encountering an error while loading
    modifier.

    """
    import ecpy.__main__ as em

    def false_iter(arg):
        class FalseEntryPoint(EntryPoint):
            def load(self, *args, **kwargs):
                raise Exception("Can't load entry point")

        return [FalseEntryPoint('dummy', 'dummy')]

    monkeypatch.setattr(em, 'iter_entry_points', false_iter)

    def check_dialog(dial):
        assert 'extension' in dial.text

    with pytest.raises(SystemExit):
        with handle_dialog('reject', check_dialog):
            main([])
Exemple #12
0
def test_running_main_error_in_loading(windows, monkeypatch):
    """Test starting the main app but encountering an error while loading
    modifier.

    """
    import ecpy.__main__ as em

    def false_iter(arg):

        class FalseEntryPoint(EntryPoint):
            def load(self, *args, **kwargs):
                raise Exception("Can't load entry point")

        return [FalseEntryPoint('dummy', 'dummy')]

    monkeypatch.setattr(em, 'iter_entry_points', false_iter)

    def check_dialog(dial):
        assert 'extension' in dial.text

    with pytest.raises(SystemExit):
        with handle_dialog('reject', check_dialog):
            main([])