def test_update_config_file_errors(path='foo'): f = MockFile(path, content='') with pytest.raises(IOError): update_config('bar', f.append) assert f.content == ''
def test_update_config_append_into_file(orig_content, expected_result, content_to_add): f = MockFile('foo', orig_content) update_config('foo', content_to_add, f.exists, f.append) assert f.content == expected_result
def test_update_config_append_into_file(content, expected): path = 'bar' f = MockFile(path, content) update_config(path, f.exists, f.append) assert f.content == content + expected
def test_update_config_file_errors(): path = 'foo' new_content = ['fdfgdfg', 'gnbfgnf'] f = MockFile(path, content='') with pytest.raises(IOError): update_config('bar', new_content, f.exists, f.append) assert f.content == ''
def test_update_config_append_into_file(content): path = 'bar' fmt_input = "\n{comment_line}\n{content}\n".format( comment_line='" content added by Leapp', content='\n'.join(new_macros)) f = MockFile(path, content) res = update_config(path, f.append) assert res is None assert f.content == content + fmt_input