Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_configuration_modify_defaults(self):
import redislite.configuration
result = redislite.configuration.config(daemonize="no")
self.assertIn('\ndaemonize no', result)
# ensure the global defaults are not modified
self.assertEquals(
redislite.configuration.DEFAULT_REDIS_SETTINGS["daemonize"], "yes"
)
self.redis_configuration_filename = os.path.join(
self.redis_dir, 'redis.config'
)
kwargs = dict(self.server_config)
kwargs.update(
{
'pidfile': self.pidfile,
'logfile': kwargs.get('logfile', self.logfile),
'unixsocket': self.socket_file,
'dbdir': self.dbdir,
'dbfilename': self.dbfilename
}
)
# Write a redis.config to our temp directory
self.redis_configuration = configuration.config(**kwargs)
with open(self.redis_configuration_filename, 'w') as file_handle:
file_handle.write(self.redis_configuration)
redis_executable = __redis_executable__
if not redis_executable: # pragma: no cover
redis_executable = 'redis-server'
command = [redis_executable, self.redis_configuration_filename]
logger.debug('Running: %s', ' '.join(command))
rc = subprocess.call(command)
if rc: # pragma: no cover
logger.debug('The binary redis-server failed to start')
redis_log = os.path.join(self.redis_dir, 'redis.log')
if os.path.exists(redis_log):
with open(redis_log) as file_handle:
logger.debug(file_handle.read())
raise RedisLiteException('The binary redis-server failed to start')