def test_wrap_settings(): fn = lambda _, settings: settings assert wrap_settings({'key': 'val'})(fn)(None, Settings({})) \ == {'key': 'val'} assert wrap_settings({'key': 'new-val'})(fn)(None, Settings({'key': 'val'})) == { 'key': 'new-val' }
def test_get_new_command_with_settings(mocker, monkeypatch, test): mocker.patch('os.path.isfile', return_value=True) monkeypatch.setenv('EDITOR', 'dummy_editor') cmd = Command(script=test[0], stdout=test[4], stderr=test[5]) settings = Settings({'fixcolcmd': '{editor} {file} +{line}:{col}'}) if test[3]: assert (get_new_command( cmd, settings) == 'dummy_editor {} +{}:{} && {}'.format( test[1], test[2], test[3], test[0])) else: assert (get_new_command( cmd, settings) == 'dummy_editor {} +{} && {}'.format( test[1], test[2], test[0]))
def test_wrap_settings(override, old, new): fn = lambda _, settings: settings assert wrap_settings(override)(fn)(None, Settings(old)) == new
def test_update_settings(): settings = Settings({'key': 'val'}) new_settings = settings.update(key='new-val') assert new_settings.key == 'new-val' assert settings.key == 'val'