2010-12-22 16:36:31 +00:00
|
|
|
# See http://code.google.com/p/python-nose/issues/detail?id=373
|
|
|
|
# The code below enables nosetests to work with i18n _() blocks
|
|
|
|
|
|
|
|
import __builtin__
|
2011-02-22 22:25:38 -06:00
|
|
|
import sys
|
2011-02-22 18:00:11 -06:00
|
|
|
import os
|
|
|
|
from ConfigParser import MissingSectionHeaderError
|
2011-02-24 12:28:17 -06:00
|
|
|
from StringIO import StringIO
|
2011-02-22 18:00:11 -06:00
|
|
|
|
|
|
|
from swift.common.utils import readconf
|
2010-12-22 16:36:31 +00:00
|
|
|
|
|
|
|
setattr(__builtin__, '_', lambda x: x)
|
|
|
|
|
2011-02-24 16:21:14 -06:00
|
|
|
|
2011-08-02 22:55:13 -07:00
|
|
|
# Work around what seems to be a Python bug.
|
|
|
|
# c.f. https://bugs.launchpad.net/swift/+bug/820185.
|
|
|
|
import logging
|
|
|
|
logging.raiseExceptions = False
|
|
|
|
|
|
|
|
|
2011-02-23 11:29:06 -06:00
|
|
|
def get_config():
|
2011-02-24 16:21:14 -06:00
|
|
|
"""
|
|
|
|
Attempt to get a functional config dictionary.
|
|
|
|
"""
|
2011-02-22 18:00:11 -06:00
|
|
|
config_file = os.environ.get('SWIFT_TEST_CONFIG_FILE',
|
|
|
|
'/etc/swift/func_test.conf')
|
|
|
|
config = {}
|
|
|
|
try:
|
2011-02-24 12:28:17 -06:00
|
|
|
try:
|
|
|
|
config = readconf(config_file, 'func_test')
|
|
|
|
except MissingSectionHeaderError:
|
|
|
|
config_fp = StringIO('[func_test]\n' + open(config_file).read())
|
|
|
|
config = readconf(config_fp, 'func_test')
|
2011-02-22 18:00:11 -06:00
|
|
|
except SystemExit:
|
2011-02-24 11:59:34 -06:00
|
|
|
print >>sys.stderr, 'UNABLE TO READ FUNCTIONAL TESTS CONFIG FILE'
|
2011-02-22 18:00:11 -06:00
|
|
|
return config
|