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()

limit_test ( obj,
attrname,
min,
max )

Definition at line 19 of file test_configobject.py.

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

◆ limit_test_raise()

limit_test_raise ( obj,
attrname,
min,
max )

Definition at line 34 of file test_configobject.py.

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

Variable Documentation

◆ scriptsdir

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

Definition at line 17 of file test_configobject.py.