Beispiel #1
0
 def testFailures(self):
     input_file = InputFile()
     with self.assertRaises(PeacockException.PeacockException):
         input_file.openInputFile("/no_exist")
     with self.assertRaises(PeacockException.PeacockException):
         input_file.openInputFile("/")
     with self.assertRaises(PeacockException.PeacockException):
         self.writeFile(self.basic_input, self.tmp_bad_file)
         input_file.openInputFile(self.tmp_bad_file)
     with self.assertRaises(PeacockException.PeacockException):
         # simulate a duplicate section in the input file
         # which should throw an exception
         self.writeFile(self.basic_input * 2, self.tmp_file)
         input_file.openInputFile(self.tmp_file)
Beispiel #2
0
 def testFailures(self):
     input_file = InputFile()
     with self.assertRaises(PeacockException.PeacockException):
         input_file.openInputFile("/no_exist")
     with self.assertRaises(PeacockException.PeacockException):
         input_file.openInputFile("/")
     with self.assertRaises(PeacockException.PeacockException):
         self.writeFile(self.basic_input, self.tmp_bad_file)
         input_file.openInputFile(self.tmp_bad_file)
     with self.assertRaises(PeacockException.PeacockException):
         # simulate a duplicate section in the input file
         # which should throw an exception
         self.writeFile(self.basic_input*2, self.tmp_file)
         input_file.openInputFile(self.tmp_file)
Beispiel #3
0
 def testSuccess(self):
     self.writeFile(self.basic_input, self.tmp_file)
     input_file = InputFile(self.tmp_file)
     self.assertNotEqual(input_file.root_node, None)
     self.assertEqual(input_file.changed, False)
     children = [ c for c in input_file.root_node.children(node_type=hit.NodeType.Section) ]
     self.assertEqual(len(children), 1)
     top = children[0]
     self.assertEqual(top.path(), "foo")
     children = [ c for c in top.children(node_type=hit.NodeType.Section) ]
     self.assertEqual(len(children), 2)
     c0 = children[0]
     self.assertEqual(c0.path(), "bar")
     params = [ c for c in c0.children(node_type=hit.NodeType.Field) ]
     self.assertEqual(len(params), 2)
     c1 = children[1]
     self.assertEqual(c1.path(), "foobar")
     params = [ c for c in c1.children(node_type=hit.NodeType.Field) ]
     self.assertEqual(len(params), 1)
Beispiel #4
0
 def createBasic(self):
     self.writeFile(self.basic_input)
     input_file = InputFile(self.tmp_file)
     self.assertNotEqual(input_file.root_node, None)
     self.assertEqual(input_file.root_node.children.keys(), ["foo"])
     return input_file