DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
test_configobject Namespace Reference

Classes

class  ConfigObject
 

Functions

 limit_test (obj, attrname, min, max)
 
 limit_test_raise (obj, attrname, min, max)
 

Variables

 scriptsdir = os.path.dirname(os.path.realpath(__file__))
 

Detailed Description

Unit test for the Python bindings to the ConfigObject class.

Function Documentation

◆ limit_test()

test_configobject.limit_test ( obj,
attrname,
min,
max )

Definition at line 14 of file test_configobject.py.

14def limit_test(obj, attrname, min, max):
15 db = conffwk.Configuration("oksconflibs")
16 db.create_db('test.data.xml', [f'{scriptsdir}/test.schema.xml'])
17
18 low = db.create_obj("Dummy", "TestDummy-Low")
19 low[attrname] = min
20 obj.assertEqual(low[attrname], min)
21
22 high = db.create_obj("Dummy", "TestDummy-High")
23 high[attrname] = max
24 obj.assertEqual(high[attrname], max)
25
26 db.commit()
27
28

◆ limit_test_raise()

test_configobject.limit_test_raise ( obj,
attrname,
min,
max )

Definition at line 29 of file test_configobject.py.

29def limit_test_raise(obj, attrname, min, max):
30 db = conffwk.Configuration("oksconflibs")
31 filename = 'overflow_test.data.xml'
32 db.create_db(filename, [f'{scriptsdir}/test.schema.xml'])
33
34 low = db.create_obj("Dummy", "TestDummy-Underflow")
35
36 #obj.assertRaises(OverflowError, low.__setitem__, attrname, min-1)
37 obj.assertRaises(TypeError, low.__setitem__, attrname, min-1)
38
39 high = db.create_obj("Dummy", "TestDummy-Overflow")
40 #obj.assertRaises(OverflowError, high.__setitem__, attrname, max+1)
41 obj.assertRaises(TypeError, high.__setitem__, attrname, max+1)
42
43 db.commit()
44
45

Variable Documentation

◆ scriptsdir

test_configobject.scriptsdir = os.path.dirname(os.path.realpath(__file__))

Definition at line 12 of file test_configobject.py.