Merge pull request #154 from ulope/issue154

config file option doesn't work for dotted names
main
Vincent Driessen 12 years ago
commit a543a3860f

@ -1,3 +1,4 @@
import importlib
import redis import redis
from rq import use_connection from rq import use_connection
@ -19,7 +20,7 @@ def add_standard_arguments(parser):
def read_config_file(module): def read_config_file(module):
"""Reads all UPPERCASE variables defined in the given module file.""" """Reads all UPPERCASE variables defined in the given module file."""
settings = __import__(module, [], [], [], -1) settings = importlib.import_module(module)
return dict([(k, v) return dict([(k, v)
for k, v in settings.__dict__.items() for k, v in settings.__dict__.items()
if k.upper() == k]) if k.upper() == k])

@ -0,0 +1 @@
REDIS_HOST = "testhost.example.com"

@ -0,0 +1,8 @@
from unittest import TestCase
from rq.scripts import read_config_file
class TestScripts(TestCase):
def test_config_file(self):
settings = read_config_file("tests.dummy_settings")
self.assertIn("REDIS_HOST", settings)
self.assertEqual(settings['REDIS_HOST'], "testhost.example.com")
Loading…
Cancel
Save