~david-goetz/swift/wal

« back to all changes in this revision

Viewing changes to test/__init__.py

  • Committer: David Goetz
  • Date: 2011-05-02 19:59:51 UTC
  • mfrom: (203.2.83 swift)
  • Revision ID: david.goetz@rackspace.com-20110502195951-w15psa53urkqhoml
update to trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
# The code below enables nosetests to work with i18n _() blocks
3
3
 
4
4
import __builtin__
 
5
import sys
 
6
import os
 
7
from ConfigParser import MissingSectionHeaderError
 
8
from StringIO import StringIO
 
9
 
 
10
from swift.common.utils import readconf
5
11
 
6
12
setattr(__builtin__, '_', lambda x: x)
7
13
 
 
14
 
 
15
def get_config():
 
16
    """
 
17
    Attempt to get a functional config dictionary.
 
18
    """
 
19
    config_file = os.environ.get('SWIFT_TEST_CONFIG_FILE',
 
20
                                 '/etc/swift/func_test.conf')
 
21
    config = {}
 
22
    try:
 
23
        try:
 
24
            config = readconf(config_file, 'func_test')
 
25
        except MissingSectionHeaderError:
 
26
            config_fp = StringIO('[func_test]\n' + open(config_file).read())
 
27
            config = readconf(config_fp, 'func_test')
 
28
    except SystemExit:
 
29
        print >>sys.stderr, 'UNABLE TO READ FUNCTIONAL TESTS CONFIG FILE'
 
30
    return config