Пример #1
0
def test_qutebrowser_version_unparsable(state_writer, monkeypatch, caplog):
    state_writer('version', 'blabla')

    with caplog.at_level(logging.WARNING):
        state = configfiles.StateConfig()

    assert caplog.messages == ['Unable to parse old version blabla']
    assert state.qutebrowser_version_changed == configfiles.VersionChange.unknown
Пример #2
0
def test_qutebrowser_version_changed(
        state_writer, monkeypatch, old_version, new_version, expected):
    monkeypatch.setattr(configfiles.qutebrowser, '__version__', new_version)

    if old_version is not None:
        state_writer('version', old_version)

    state = configfiles.StateConfig()
    assert state.qutebrowser_version_changed == expected
Пример #3
0
def test_qt_version_changed(state_writer, monkeypatch,
                            old_version, new_version, changed):
    monkeypatch.setattr(configfiles, 'qVersion', lambda: new_version)

    if old_version is not None:
        state_writer('qt_version', old_version)

    state = configfiles.StateConfig()
    assert state.qt_version_changed == changed
Пример #4
0
def test_qt_version_changed(data_tmpdir, monkeypatch, old_version, new_version,
                            changed):
    monkeypatch.setattr(configfiles, 'qVersion', lambda: new_version)

    statefile = data_tmpdir / 'state'
    if old_version is not None:
        data = ('[general]\n' 'qt_version = {}'.format(old_version))
        statefile.write_text(data, 'utf-8')

    state = configfiles.StateConfig()
    assert state.qt_version_changed == changed
Пример #5
0
def test_state_config(fake_save_manager, data_tmpdir, old_data, insert,
                      new_data):
    statefile = data_tmpdir / 'state'
    if old_data is not None:
        statefile.write_text(old_data, 'utf-8')

    state = configfiles.StateConfig()

    if insert:
        state['general']['newval'] = '23'
    # WORKAROUND for https://github.com/PyCQA/pylint/issues/574
    if 'foobar' in (old_data or ''):  # pylint: disable=superfluous-parens
        assert state['general']['foobar'] == '42'

    state._save()

    assert statefile.read_text('utf-8') == new_data
Пример #6
0
def test_state_config(fake_save_manager, data_tmpdir, old_data, insert,
                      new_data):
    statefile = data_tmpdir / 'state'
    if old_data is not None:
        statefile.write_text(old_data, 'utf-8')

    state = configfiles.StateConfig()
    state.init_save_manager(fake_save_manager)

    if insert:
        state['general']['newval'] = '23'
    if 'foobar' in (old_data or ''):
        assert state['general']['foobar'] == '42'

    state._save()

    assert statefile.read_text('utf-8') == new_data
    fake_save_manager.add_saveable('state-config', unittest.mock.ANY)
Пример #7
0
def test_state_config(fake_save_manager, data_tmpdir, monkeypatch, old_data,
                      insert, new_data):
    monkeypatch.setattr(configfiles.qutebrowser, '__version__', '1.2.3')
    monkeypatch.setattr(configfiles, 'qVersion', lambda: '5.6.7')

    statefile = data_tmpdir / 'state'
    if old_data is not None:
        statefile.write_text(old_data, 'utf-8')

    state = configfiles.StateConfig()
    state.init_save_manager(fake_save_manager)

    if insert:
        state['general']['newval'] = '23'
    if 'foobar' in (old_data or ''):
        assert state['general']['foobar'] == '42'

    state._save()

    assert statefile.read_text('utf-8') == new_data
    fake_save_manager.add_saveable('state-config', unittest.mock.ANY)
Пример #8
0
def state_config(data_tmpdir, monkeypatch):
    state = configfiles.StateConfig()
    monkeypatch.setattr(configfiles, 'state', state)
    return state