def _update_config(cls, env_key: str, value: str): replace_line(settings_path, lambda line: line.startswith('{}='.format(env_key)), '{}={}'.format(env_key, value)) config_key = env_key.replace('OPWEN_', '') setattr(AppConfig, config_key, value) environ[env_key] = value return True
def _update_config(cls, env_key: str, value: str): replace_line( settings_path, lambda line: line.startswith('{}='.format(env_key)), '{}={}'.format(env_key, value)) config_key = env_key.replace('OPWEN_', '') setattr(AppConfig, config_key, value) environ[env_key] = value return True
def test_replaces_line(self): fobj = NamedTemporaryFile('w+', delete=False) try: fobj.write('foo\nbar\nbaz') fobj.close() replace_line(fobj.name, lambda line: line.startswith('ba'), 'changed') with open(fobj.name) as changed: content = changed.read() self.assertEqual(content, 'foo\nchanged\nchanged') finally: remove(fobj.name)
def test_replaces_line(self): fobj = NamedTemporaryFile('w+', delete=False) try: fobj.write('foo\nbar\nbaz') fobj.close() replace_line( fobj.name, lambda line: line.startswith('ba'), 'changed') with open(fobj.name) as changed: content = changed.read() self.assertEqual(content, 'foo\nchanged\nchanged') finally: remove(fobj.name)