コード例 #1
0
def test_store_dirname_returns_the_old_value_if_no_new_value():
    settings = MockSettings({'k': '/old/dir'})

    @store_dirname_in_settings(key='k', settings=settings)
    def f():
        return ''

    f()
    assert settings.value('k') == '/old/dir'
コード例 #2
0
def test_store_result_should_store_results_in_settings():
    settings = MockSettings()

    @store_results_in_settings(key='k', settings=settings)
    def f():
        return 45

    f()
    assert settings.value('k') == 45
コード例 #3
0
def test_store_dirname_in_settings_stores_the_resulting_dir_in_settings():
    settings = MockSettings()

    @store_dirname_in_settings(key='d', settings=settings)
    def f():
        return '/test/file.json'

    f()
    assert settings.value('d') == '/test'
コード例 #4
0
def test_store_result_should_let_you_transform_the_result_before_storing():
    settings = MockSettings()
    double = lambda x: x + x

    @store_results_in_settings(key='k', settings=settings, transform=double)
    def f():
        return 10

    f()
    assert settings.value('k') == 20
コード例 #5
0
def settings():
    mock_settings = MockSettings()

    yield mock_settings

    del mock_settings
コード例 #6
0
def test_apply_settings_sets_row_to_zero_if_stored_index_out_of_bounds(
        power_hour_list_view, item_model):
    index = item_model.rowCount()
    settings = MockSettings({'power_hour_list_view/row': index})
    power_hour_list_view.apply_settings(settings)
    assert power_hour_list_view.currentIndex().row() == 0
コード例 #7
0
def test_apply_settings_sets_the_index_from_settings(power_hour_list_view):
    index = 2
    settings = MockSettings({'power_hour_list_view/row': index})
    power_hour_list_view.apply_settings(settings)
    assert power_hour_list_view.currentIndex().row() == index