示例#1
0
def test_change_ui_theme_and_color_scheme(config_dialog, mocker, qtbot):
    """Test that changing color scheme or UI theme works as expected."""
    # Patch methods whose calls we want to check
    mocker.patch.object(SpyderConfigPage, "prompt_restart_required")

    # Get reference to Preferences dialog and widget page to interact with
    dlg = config_dialog
    widget = config_dialog.get_page()

    # List of color schemes
    names = widget.get_option('names')

    # Assert no restarts have been requested so far.
    assert SpyderConfigPage.prompt_restart_required.call_count == 0

    # Assert default UI theme is 'automatic' and interface is dark. The other
    # tests below depend on this.
    assert widget.get_option('ui_theme') == 'automatic'
    assert widget.is_dark_interface()

    # Change to another dark color scheme
    widget.schemes_combobox.setCurrentIndex(names.index('monokai'))
    dlg.apply_btn.click()
    assert SpyderConfigPage.prompt_restart_required.call_count == 0

    # Change to a light color scheme
    widget.schemes_combobox.setCurrentIndex(names.index('pydev'))
    dlg.apply_btn.clicked.emit()
    assert SpyderConfigPage.prompt_restart_required.call_count == 1

    # Change to the 'dark' ui theme
    widget.ui_combobox.setCurrentIndex(2)
    dlg.apply_btn.clicked.emit()
    assert SpyderConfigPage.prompt_restart_required.call_count == 1

    # Change to the 'automatic' ui theme
    widget.ui_combobox.setCurrentIndex(0)
    dlg.apply_btn.clicked.emit()
    assert SpyderConfigPage.prompt_restart_required.call_count == 2

    # Change to the 'light' ui theme
    widget.ui_combobox.setCurrentIndex(1)
    dlg.apply_btn.clicked.emit()
    assert SpyderConfigPage.prompt_restart_required.call_count == 3

    # Change to another dark color scheme
    widget.schemes_combobox.setCurrentIndex(names.index('solarized/dark'))
    dlg.apply_btn.clicked.emit()
    assert SpyderConfigPage.prompt_restart_required.call_count == 4

    # Change to the 'automatic' ui theme again
    widget.ui_combobox.setCurrentIndex(0)
    dlg.apply_btn.clicked.emit()
    assert SpyderConfigPage.prompt_restart_required.call_count == 4
示例#2
0
def test_config_dialog(config_dialog):
    expected_titles = {'General', 'Snippets', 'Linting', 'Introspection',
                       'Code style and formatting', 'Docstring style',
                       'Advanced', 'Other languages'}

    configpage = config_dialog.get_page()
    assert configpage
    tabs = configpage.tabs
    for i in range(0, tabs.count()):
        tab_text = tabs.tabText(i)
        assert tab_text in expected_titles
    configpage.save_to_conf()
示例#3
0
def test_config_dialog(request, config_dialog):
    def teardown():
        # Remove fake entry points from pkg_resources
        pkg_resources.working_set.by_key.pop('unknown')
        pkg_resources.working_set.entry_keys.pop('spyder')
        pkg_resources.working_set.entry_keys.pop(__file__)
        pkg_resources.working_set.entries.remove('spyder')

    request.addfinalizer(teardown)

    configpage = config_dialog.get_page()
    assert configpage
    configpage.save_to_conf()
示例#4
0
def test_config_dialog(request, config_dialog):
    expected_titles = {'General', 'Snippets', 'Linting', 'Introspection',
                       'Code style and formatting', 'Docstring style',
                       'Advanced', 'Other languages'}

    def teardown():
        # Remove fake entry points from pkg_resources
        if not running_in_ci():
            pkg_resources.working_set.by_key.pop('unknown')
            pkg_resources.working_set.entry_keys.pop('spyder')
            pkg_resources.working_set.entry_keys.pop(__file__)
            pkg_resources.working_set.entries.remove('spyder')

    request.addfinalizer(teardown)

    configpage = config_dialog.get_page()
    assert configpage
    tabs = configpage.tabs
    for i in range(0, tabs.count()):
        tab_text = tabs.tabText(i)
        assert tab_text in expected_titles
    configpage.save_to_conf()
def test_config_dialog(config_dialog):
    configpage = config_dialog.get_page()
    configpage.save_to_conf()
    assert configpage