File: config.py

package info (click to toggle)
python-webunit 1%3A1.3.10-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 172 kB
  • ctags: 210
  • sloc: python: 1,516; makefile: 15
file content (36 lines) | stat: -rwxr-xr-x 710 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'''
This file allows you to set up configuration variables to identify the
machine and port to test.

It needs some work, but in a nutshell, put a config.cfg in your "test"
directory with the following contents:

---- snip

[DEFAULT]
machine = www.dev.ekorp.com
port = 80

[dev-ekit]
# uses DEFAULT

[dev-lp]
machine = www.lonelyplanet.dev.ekorp.com
port = 80

---- snip

Then set the environment var "TEST_CONFIG" to the config to use.

'''
import ConfigParser, os

cfg = ConfigParser.ConfigParser()
cfg.read('test/config.cfg')

# figure the active config
active = os.environ.get('TEST_CONFIG', 'DEFAULT')

# fetch the actual config info
machine = cfg.get(active, 'machine')
port = cfg.getint(active, 'port')