| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | List of all members
EnvConfig.TestEnvOps.Test Class Reference
Inheritance diagram for EnvConfig.TestEnvOps.Test:
[legend]
Collaboration diagram for EnvConfig.TestEnvOps.Test:
[legend]

## Public Member Functions
def | setUp
def | tearDown
def | testValues
def | testWrite
def | testWriteWithList
def | testSaveToXML
def | testSaveToFile
def | testSearch
def | testVariables
def | testDelete
def | testSystemEnvironment
def | testDependencies
def | testInclude
def | testFileDir
def | testDefaults
def | testVariableManipulations

## Detailed Description

Definition at line 69 of file TestEnvOps.py.

## Member Function Documentation

def EnvConfig.TestEnvOps.Test.setUp | ( |  | self | ) |

Definition at line 72 of file TestEnvOps.py.

72
73 def setUp(self):
74 pass

def EnvConfig.TestEnvOps.Test.tearDown | ( |  | self | ) |

Definition at line 75 of file TestEnvOps.py.

75
76 def tearDown(self):
77 pass
78

def EnvConfig.TestEnvOps.Test.testDefaults | ( |  | self | ) |

Definition at line 517 of file TestEnvOps.py.

517
518 def testDefaults(self):
519 tmp = TempDir({'env.xml':
520 '''<?xml version="1.0" ?>
521 <env:config xmlns:env="EnvSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="EnvSchema ./EnvSchema.xsd ">
522 <env:default variable="var1">value1</env:default>
523 <env:declare variable="var2" local="true" />
524 <env:default variable="var2">test2</env:default>
525 </env:config>'''})
526
527 if 'var1' in os.environ:
528 del os.environ['var1']
529 control = Control.Environment()
530 control.loadXML(tmp('env.xml'))
531 self.assertEqual(str(control['var1']), "value1")
532 self.assertEqual(str(control['var2']), "test2")
533
534 os.environ['var1'] = "some_value"
535 control = Control.Environment()
536 control.loadXML(tmp('env.xml'))
537 self.assertEqual(str(control['var1']), "some_value")
538 self.assertEqual(str(control['var2']), "test2")
539

def EnvConfig.TestEnvOps.Test.testDelete | ( |  | self | ) |

Definition at line 261 of file TestEnvOps.py.

261
262 def testDelete(self):
263 control = Control.Environment()
264
265 control.append('MY_PATH','myVal:anotherVal:lastVal')
266 control.remove('MY_PATH','anotherVal')
267
268 self.assertFalse('anotherVal' in control['MY_PATH'])
269 self.assertTrue('myVal' in control['MY_PATH'])
270 self.assertTrue('lastVal' in control['MY_PATH'])
271
272 control.set('MY_PATH','myVal:anotherVal:lastVal:else')
273 control.remove('MY_PATH', '^anotherVal$', False)
274 self.assertTrue('anotherVal' in control['MY_PATH'])
275 control.remove('MY_PATH', '^anotherVal$', True)
276 self.assertFalse('anotherVal' in control['MY_PATH'])
277 self.assertTrue('myVal' in control['MY_PATH'])
278 self.assertTrue('lastVal' in control['MY_PATH'])
279 self.assertTrue('lastVal' in control['MY_PATH'])
280 control.remove('MY_PATH', 'Val', True)
281 self.assertTrue('else' in control['MY_PATH'])
282 self.assertTrue(len(control['MY_PATH']) == 1)
283
284
285 control.declare('myLoc', 'scalar', False)
286 control.append('myLoc','myVal:anotherVal:lastVal')
287 control.remove('myLoc', 'Val:', True)
288 self.assertTrue(str(control['myLoc']) == 'myanotherlastVal')
289

def EnvConfig.TestEnvOps.Test.testDependencies | ( |  | self | ) |

Definition at line 306 of file TestEnvOps.py.

306
307 def testDependencies(self):
308 control = Control.Environment()
309
310 control.declare('myVar', 'list', False)
311
312 control.declare('loc', 'list', True)
313 control.append('loc','locVal')
314 control.append('loc','locVal2')
315
316 control.declare('scal', 'scalar', False)
317 control.append('scal','scalVal')
318 control.append('scal','scalVal2')
319
320 control.declare('scal2', 'scalar', True)
321 control.append('scal2','locScal')
322 control.append('scal2','locScal2')
323
324 control.set('myVar', 'newValue:$loc:endValue')
325 self.assertEqual(str(control['myVar']),'newValue:locVal:locVal2:endValue')
326
327 control.set('myVar', 'newValue:$scal:endValue')
328 self.assertEqual(str(control['myVar']),'newValue:scalValscalVal2:endValue')
329
330 control.set('myVar', 'new${scal}Value:endValue')
331 self.assertEqual(str(control['myVar']),'newscalValscalVal2Value:endValue')
332
333 control.set('myVar', 'bla:$myVar:Value')
334 self.assertEqual(str(control['myVar']),'bla:newscalValscalVal2Value:endValue:Value')
335
336 control.set('scal', 'new${scal2}Value')
337 self.assertEqual(str(control['scal']),'newlocScallocScal2Value')
338
339 control.set('scal', 'new${loc}Value')
340 self.assertEqual(str(control['scal']),'newlocVal:locVal2Value')
341
342 control.set('scal2', 'new${scal2}Value')
343 self.assertEqual(str(control['scal2']),'newlocScallocScal2Value')

def EnvConfig.TestEnvOps.Test.testFileDir | ( |  | self | ) |

Definition at line 494 of file TestEnvOps.py.

494
495 def testFileDir(self):
496 tmp = TempDir({'env.xml':
497 '''<?xml version="1.0" ?>
498 <env:config xmlns:env="EnvSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="EnvSchema ./EnvSchema.xsd ">
499 <env:set variable="mydirs">${.}</env:set>
500 <env:set variable="myparent">${.}/..</env:set>
501 </env:config>'''})
502
503 control = Control.Environment()
504 control.loadXML(tmp('env.xml'))
505 self.assertEqual(str(control['mydirs']), tmp())
506 self.assertEqual(str(control['myparent']), os.path.dirname(tmp()))
507
508 olddir = os.getcwd()
509 os.chdir(tmp())
510 try:
511 control = Control.Environment()
512 control.loadXML('env.xml')
513 self.assertEqual(str(control['mydirs']), tmp())
514 self.assertEqual(str(control['myparent']), os.path.dirname(tmp()))
515 finally:
516 os.chdir(olddir)

def EnvConfig.TestEnvOps.Test.testInclude | ( |  | self | ) |

Definition at line 344 of file TestEnvOps.py.

344
345 def testInclude(self):
346 tmp = TempDir({'first.xml':
347 '''<?xml version="1.0" ?>
348 <env:config xmlns:env="EnvSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="EnvSchema ./EnvSchema.xsd ">
349 <env:set variable="main">first</env:set>
350 <env:append variable="test_path">data1</env:append>
351 <env:include>first_inc.xml</env:include>
352 </env:config>''',
353 'second.xml':
354 '''<?xml version="1.0" ?>
355 <env:config xmlns:env="EnvSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="EnvSchema ./EnvSchema.xsd ">
356 <env:set variable="main">second</env:set>
357 <env:include>second_inc.xml</env:include>
358 <env:append variable="test_path">data1</env:append>
359 </env:config>''',
360 'third.xml':
361 '''<?xml version="1.0" ?>
362 <env:config xmlns:env="EnvSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="EnvSchema ./EnvSchema.xsd ">
363 <env:set variable="main">third</env:set>
364 <env:append variable="test_path">data1</env:append>
365 <env:include>subdir/first_inc.xml</env:include>
366 </env:config>''',
367 'fourth.xml':
368 '''<?xml version="1.0" ?>
369 <env:config xmlns:env="EnvSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="EnvSchema ./EnvSchema.xsd ">
370 <env:set variable="main">fourth</env:set>
371 <env:include hints="subdir2">fourth_inc.xml</env:include>
372 </env:config>''',
373 'recursion.xml':
374 '''<?xml version="1.0" ?>
375 <env:config xmlns:env="EnvSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="EnvSchema ./EnvSchema.xsd ">
376 <env:set variable="main">recursion</env:set>
377 <env:include>recursion.xml</env:include>
378 </env:config>''',
379 'first_inc.xml':
380 '''<?xml version="1.0" ?>
381 <env:config xmlns:env="EnvSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="EnvSchema ./EnvSchema.xsd ">
382 <env:append variable="test_path">data2</env:append>
383 <env:append variable="derived">another_${main}</env:append>
384 </env:config>''',
385 'subdir': {'second_inc.xml':
386 '''<?xml version="1.0" ?>
387 <env:config xmlns:env="EnvSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="EnvSchema ./EnvSchema.xsd ">
388 <env:append variable="test_path">data0</env:append>
389 <env:set variable="map">this_is_second_inc</env:set>
390 </env:config>''',
391 'first_inc.xml':
392 '''<?xml version="1.0" ?>
393 <env:config xmlns:env="EnvSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="EnvSchema ./EnvSchema.xsd ">
394 <env:append variable="derived">second_${main}</env:append>
395 </env:config>''',
396 'fourth_inc.xml':
397 '''<?xml version="1.0" ?>
398 <env:config xmlns:env="EnvSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="EnvSchema ./EnvSchema.xsd ">
399 <env:append variable="included">from subdir</env:append>
400 </env:config>''',},
401 'subdir2': {'fourth_inc.xml':
402 '''<?xml version="1.0" ?>
403 <env:config xmlns:env="EnvSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="EnvSchema ./EnvSchema.xsd ">
404 <env:append variable="included">from subdir2</env:append>
405 </env:config>''',}})
406
407 # set the basic search path to the minimal default
408 if 'ENVXMLPATH' in os.environ:
409 del os.environ['ENVXMLPATH']
410 import EnvConfig
411 saved_path = list(EnvConfig.path)
412 EnvConfig.path[:] = ['.']
413
414 control = Control.Environment(searchPath=[])
415
416 #self.assertRaises(OSError, control.loadXML, tmp('first.xml'))
417 control.loadXML(tmp('first.xml'))
418 self.assertEqual(str(control['main']), 'first')
419 self.assertEqual(str(control['test_path']), 'data1:data2')
420 self.assertEqual(str(control['derived']), 'another_first')
421
422 control = Control.Environment(searchPath=[tmp()])
423 control.loadXML(tmp('first.xml'))
424 self.assertEqual(str(control['main']), 'first')
425 self.assertEqual(str(control['test_path']), 'data1:data2')
426 self.assertEqual(str(control['derived']), 'another_first')
427
428 control = Control.Environment(searchPath=[tmp()])
429 control.loadXML('first.xml')
430 self.assertEqual(str(control['main']), 'first')
431 self.assertEqual(str(control['test_path']), 'data1:data2')
432 self.assertEqual(str(control['derived']), 'another_first')
433
434 control = Control.Environment(searchPath=[tmp()])
435 self.assertRaises(OSError, control.loadXML, tmp('second.xml'))
436
437 control = Control.Environment(searchPath=[tmp(), tmp('subdir')])
438 control.loadXML(tmp('second.xml'))
439 self.assertEqual(str(control['main']), 'second')
440 self.assertEqual(str(control['test_path']), 'data0:data1')
441 self.assertEqual(str(control['map']), 'this_is_second_inc')
442
443 control = Control.Environment(searchPath=[tmp(), tmp('subdir')])
444 control.loadXML(tmp('first.xml'))
445 self.assertEqual(str(control['main']), 'first')
446 self.assertEqual(str(control['test_path']), 'data1:data2')
447 self.assertEqual(str(control['derived']), 'another_first')
448
449 control = Control.Environment(searchPath=[tmp('subdir'), tmp()])
450 control.loadXML(tmp('first.xml'))
451 self.assertEqual(str(control['main']), 'first')
452 self.assertEqual(str(control['test_path']), 'data1:data2')
453 self.assertEqual(str(control['derived']), 'another_first')
454
455 control = Control.Environment(searchPath=[tmp('subdir'), tmp()])
456 control.loadXML('first.xml')
457 self.assertEqual(str(control['main']), 'first')
458 self.assertEqual(str(control['test_path']), 'data1:data2')
459 self.assertEqual(str(control['derived']), 'another_first')
460
461 #os.environ['ENVXMLPATH'] = os.pathsep.join([tmp(), tmp('subdir')])
462 EnvConfig.path[:] = ['.', tmp(), tmp('subdir')]
463 control = Control.Environment(searchPath=[])
464 control.loadXML(tmp('second.xml'))
465 self.assertEqual(str(control['main']), 'second')
466 self.assertEqual(str(control['test_path']), 'data0:data1')
467 self.assertEqual(str(control['map']), 'this_is_second_inc')
468 #del os.environ['ENVXMLPATH']
469 EnvConfig.path[:] = ['.']
470
471 control = Control.Environment(searchPath=[])
472 control.loadXML(tmp('third.xml'))
473 self.assertEqual(str(control['main']), 'third')
474 self.assertEqual(str(control['test_path']), 'data1')
475 self.assertEqual(str(control['derived']), 'second_third')
476
477 control = Control.Environment(searchPath=[tmp('subdir')])
478 control.loadXML(tmp('fourth.xml'))
479 self.assertEqual(str(control['main']), 'fourth')
480 self.assertEqual(str(control['included']), 'from subdir')
481
482 control = Control.Environment(searchPath=[])
483 control.loadXML(tmp('fourth.xml'))
484 self.assertEqual(str(control['main']), 'fourth')
485 self.assertEqual(str(control['included']), 'from subdir2')
486
487 control = Control.Environment(searchPath=[])
488 #self.assertRaises(OSError, control.loadXML, tmp('first.xml'))
489 control.loadXML(tmp('recursion.xml'))
490
491 # restore search path
492 EnvConfig.path = saved_path
493

def EnvConfig.TestEnvOps.Test.testSaveToFile | ( |  | self | ) |

    Test addition of variable to system

Definition at line 178 of file TestEnvOps.py.

178
179 def testSaveToFile(self):
180 '''Test addition of variable to system'''
181 control = Control.Environment()
182
183 control.append('sysVar', 'newValue:lala')
184 control.writeToFile('setupFile.txt')
185
186 with open('setupFile.txt', "r") as f:
187 f.readline()
188 stri = f.readline()
189 f.close()
190
191 self.assertEqual(stri, 'export sysVar=newValue:lala\n')
192
193 os.remove('setupFile.txt')

def EnvConfig.TestEnvOps.Test.testSaveToXML | ( |  | self | ) |

    XML file write and load test

Definition at line 154 of file TestEnvOps.py.

154
155 def testSaveToXML(self):
156 """XML file write and load test"""
157 control = Control.Environment()
158
159 control.unset('MY_PATH')
160 control.set('MY_PATH', 'set:toDelete')
161 control.append('MY_PATH', 'appended:toDelete')
162 control.prepend('MY_PATH', 'prepended:toDelete')
163 control.remove('MY_PATH', 'toDelete')
164 control.writeToXMLFile('testOutputFile.xml')
165
166 control = Control.Environment()
167 self.assertFalse('MY_PATH' in control.vars())
168 control.loadXML('testOutputFile.xml')
169
170 self.assertTrue('MY_PATH' in control.vars())
171 var = control.var('MY_PATH')
172 self.assertTrue(var[0] == 'prepended')
173 self.assertTrue(var[1] == 'set')
174 self.assertTrue(var[2] == 'appended')
175 self.assertFalse('toDelete' in var)
176
177 os.remove('testOutputFile.xml')

def EnvConfig.TestEnvOps.Test.testSearch | ( |  | self | ) |

    Testing searching in variables

Definition at line 194 of file TestEnvOps.py.

194
195 def testSearch(self):
196 '''Testing searching in variables'''
197 control = Control.Environment()
198
199 control.append('MY_PATH', 'newValue:mess:something new:aaaabbcc')
200
201 def count(val, regExp = False):
202 return len(control.search('MY_PATH', val, regExp))
203
204 self.assertEqual(count('new'), 0)
205 self.assertEqual(count('newValue'), 1)
206
207 self.assertEqual(count('me', False), 0)
208 self.assertEqual(count('me', True), 2)
209
210 self.assertEqual(count('cc', False), 0)
211 self.assertEqual(count('cc', True), 1)
212
213 self.assertEqual(count('a{2}b{2}c{2}', True), 1)
214 self.assertEqual(count('a{2}b{2}', True), 1)
215 self.assertEqual(count('a{1}b{2}c{2}', True), 1)
216 self.assertEqual(count('a{1}b{1}c{2}', True), 0)
217 self.assertEqual(count('a{1,2}b{1,2}c{2}', True), 1)
218 self.assertEqual(count('a{2,3}', True), 1)
219 self.assertEqual(count('a{2,3}?', True), 1)

def EnvConfig.TestEnvOps.Test.testSystemEnvironment | ( |  | self | ) |

Definition at line 290 of file TestEnvOps.py.

290
291 def testSystemEnvironment(self):
292 control = Control.Environment()
293
294 os.environ['MY_PATH'] = '$myVal'
295 os.environ['myScal'] = '$myVal'
296
297 control.set('ABC','anyValue')
298 control.declare('MY_PATH', 'list', False)
299 control.append('MY_PATH','$ABC')
300 self.assertTrue(control['MY_PATH'].value(True) == '$myVal:anyValue')
301
302 control.declare('myScal', 'scalar', False)
303 control.append('myScal', '$ABC')
304 self.assertTrue(control['myScal'].value(True) == '$myValanyValue')
305

def EnvConfig.TestEnvOps.Test.testValues | ( |  | self | ) |

    Test of value appending, prepending, setting, unsetting, removing

Definition at line 79 of file TestEnvOps.py.

79
80 def testValues(self):
81 '''Test of value appending, prepending, setting, unsetting, removing'''
82 control = Control.Environment()
83
84 self.assertFalse('MY_PATH' in control.vars())
85 control.append('MY_PATH', 'newValue')
86 self.assertTrue('MY_PATH' in control.vars())
87 var = control.var('MY_PATH')
88
89 control.append('MY_PATH', 'newValue:secondVal:valval')
90 self.assertTrue(var[len(var)-1] == 'valval')
91
92 self.assertTrue('newValue' in var)
93 control.remove('MY_PATH', 'newValue')
94 self.assertFalse('newValue' in var)
95
96 control.prepend('MY_PATH', 'newValue')
97 self.assertTrue('newValue' == var[0])
98
99 control.set('MY_PATH', 'hi:hello')
100 self.assertTrue(len(var) == 2)
101 self.assertTrue('hi' == var[0])
102
103 control.unset('MY_PATH')
104 self.assertTrue('MY_PATH' not in control)
105

def EnvConfig.TestEnvOps.Test.testVariableManipulations | ( |  | self | ) |

Definition at line 540 of file TestEnvOps.py.

540
541 def testVariableManipulations(self):
542 l = Variable.List('PATH')
543
544 l.set("/usr/bin:/some//strange/../nice/./location")
545 assert l.value(asString=True) == "/usr/bin:/some/nice/location"
546
547 l.append("/another/path")
548 assert l.value(asString=True) == "/usr/bin:/some/nice/location:/another/path"
549
550 # duplicates removal
551 l.append("/usr/bin")
552 assert l.value(asString=True) == "/usr/bin:/some/nice/location:/another/path"
553 l.prepend("/another/path")
554 assert l.value(asString=True) == "/another/path:/usr/bin:/some/nice/location"
555
556 s = Variable.Scalar('VAR')
557
558 s.set("/usr/bin")
559 assert s.value(asString=True) == "/usr/bin"
560
561 s.set("/some//strange/../nice/./location")
562 assert s.value(asString=True) == "/some/nice/location"
563
564 # This is undefined
565 # l.set("http://cern.ch")
566
567 s.set("http://cern.ch")
568 assert s.value(asString=True) == "http://cern.ch"

def EnvConfig.TestEnvOps.Test.testVariables | ( |  | self | ) |

    Tests variables creation and redeclaration.

Definition at line 220 of file TestEnvOps.py.

220
221 def testVariables(self):
222 '''Tests variables creation and redeclaration.'''
223 control = Control.Environment()
224
225 control.append('MY_PATH', 'newValue')
226 self.assertFalse(control.var('MY_PATH').local)
227 self.assertTrue(isinstance(control.var('MY_PATH'),Variable.List))
228
229 control.declare('loc', 'list', True)
230 self.assertTrue(control.var('loc').local)
231 self.assertTrue(isinstance(control.var('loc'),Variable.List))
232
233 control.declare('myVar2', 'scalar', False)
234 self.assertFalse(control.var('myVar2').local)
235 self.assertTrue(isinstance(control.var('myVar2'),Variable.Scalar))
236
237 control.declare('loc2', 'scalar', True)
238 self.assertTrue(control.var('loc2').local)
239 self.assertTrue(isinstance(control.var('loc2'),Variable.Scalar))
240
241 control.declare('MY_PATH', 'list', False)
242 self.failUnlessRaises(Variable.EnvError, control.declare, 'MY_PATH', 'list', True)
243 self.failUnlessRaises(Variable.EnvError, control.declare, 'MY_PATH', 'scalar', True)
244 self.failUnlessRaises(Variable.EnvError, control.declare, 'MY_PATH', 'scalar', True)
245
246 control.declare('loc', 'list', True)
247 self.failUnlessRaises(Variable.EnvError, control.declare,'loc', 'list', False)
248 self.failUnlessRaises(Variable.EnvError, control.declare,'loc', 'scalar', True)
249 self.failUnlessRaises(Variable.EnvError, control.declare,'loc', 'scalar', True)
250
251 control.declare('myVar2', 'scalar', False)
252 self.failUnlessRaises(Variable.EnvError, control.declare,'myVar2', 'list', False)
253 self.failUnlessRaises(Variable.EnvError, control.declare,'myVar2', 'list', True)
254 self.failUnlessRaises(Variable.EnvError, control.declare,'myVar2', 'scalar', True)
255
256 control.declare('loc2', 'scalar', True)
257 self.failUnlessRaises(Variable.EnvError, control.declare,'loc2', 'list', False)
258 self.failUnlessRaises(Variable.EnvError, control.declare,'loc2', 'list', True)
259 self.failUnlessRaises(Variable.EnvError, control.declare,'loc2', 'scalar', False)
260

def EnvConfig.TestEnvOps.Test.testWrite | ( |  | self | ) |

    XML file write and load test

Definition at line 106 of file TestEnvOps.py.

106
107 def testWrite(self):
108 """XML file write and load test"""
109 control = Control.Environment(useAsWriter = True)
110 control.unset('MY_PATH')
111 control.set('MY_PATH', 'set:toDelete')
112 control.append('MY_PATH', 'appended:toDelete')
113 control.prepend('MY_PATH', 'prepended:toDelete')
114 control.remove('MY_PATH', 'toDelete')
115 control.finishXMLinput('testOutputFile.xml')
116
117 control = Control.Environment()
118 self.assertFalse('MY_PATH' in control.vars())
119 control.loadXML('testOutputFile.xml')
120
121 self.assertTrue('MY_PATH' in control.vars())
122 var = control.var('MY_PATH')
123 self.assertTrue(var[0] == 'prepended')
124 self.assertTrue(var[1] == 'set')
125 self.assertTrue(var[2] == 'appended')
126 self.assertFalse('toDelete' in var)
127
128 os.remove('testOutputFile.xml')
129

def EnvConfig.TestEnvOps.Test.testWriteWithList | ( |  | self | ) |

    XML file write and load test

Definition at line 130 of file TestEnvOps.py.

130
131 def testWriteWithList(self):
132 """XML file write and load test"""
133 control = Control.Environment(useAsWriter = True)
134 control.unset('MY_PATH')
135 control.set('MY_PATH', ['set','toDelete'])
136 control.append('MY_PATH', ['appended','toDelete'])
137 control.prepend('MY_PATH', ['prepended','toDelete'])
138 control.remove('MY_PATH', ['toDelete'])
139 control.finishXMLinput('testOutputFile.xml')
140
141 control = Control.Environment()
142 self.assertFalse('MY_PATH' in control.vars())
143 control.loadXML('testOutputFile.xml')
144
145 self.assertTrue('MY_PATH' in control.vars())
146 var = control.var('MY_PATH')
147 self.assertTrue(var[0] == 'prepended')
148 self.assertTrue(var[1] == 'set')
149 self.assertTrue(var[2] == 'appended')
150 self.assertFalse('toDelete' in var)
151
152 os.remove('testOutputFile.xml')
153

The documentation for this class was generated from the following file:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v25r0/cmake/EnvConfig/TestEnvOps.py