summaryrefslogtreecommitdiffstats
path: root/rteval/rtevalConfig.py
diff options
context:
space:
mode:
authorDavid Sommerseth <davids@redhat.com>2010-05-14 19:03:50 +0200
committerDavid Sommerseth <davids@redhat.com>2010-05-14 19:03:50 +0200
commit09c18db0baebb77c02de066638ad2ed27edb15cc (patch)
tree7aeb83d54da507f267694fa0162256a576515b14 /rteval/rtevalConfig.py
parent1a9c5a4c7372c5dead09254b11c844debcc2a26c (diff)
downloadrteval-09c18db0baebb77c02de066638ad2ed27edb15cc.tar.gz
rteval-09c18db0baebb77c02de066638ad2ed27edb15cc.tar.xz
rteval-09c18db0baebb77c02de066638ad2ed27edb15cc.zip
Added unit-tests
Added a generic unit-test framework and rewritten the self-test parts in some rteval modules where this was appropriate. The unit-test contains a list of modules to load and test. It will run a function named unit_test() in the imported modules. It is expected that the unit_test() function will return 0 on success, otherwise it is logged as an error.
Diffstat (limited to 'rteval/rtevalConfig.py')
-rw-r--r--rteval/rtevalConfig.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/rteval/rtevalConfig.py b/rteval/rtevalConfig.py
index 5fad260..bb77da2 100644
--- a/rteval/rtevalConfig.py
+++ b/rteval/rtevalConfig.py
@@ -185,3 +185,19 @@ class rtevalConfig(rtevalCfgSection):
return rtevalCfgSection(self.__config_data[section])
except KeyError, err:
raise KeyError("The section '%s' does not exist in the config file" % section)
+
+
+def unit_test(rootdir):
+ try:
+ cfg = rtevalConfig()
+ cfg.Load(rootdir + '/rteval/rteval.conf')
+ print cfg
+ return 0
+ except Exception, e:
+ print "** EXCEPTION %s", str(e)
+ return 1
+
+
+if __name__ == '__main__':
+ import sys
+ sys.exit(unit_test('..'))