示例#1
0
 def test_try_parse_with_bad_file(self):
     """Should raise XMLSyntaxError: file exists but content is not valid."""
     xml_path = os.path.join(self.cwd, "test_try_parse.xml")
     self.tidy_file = xml_path
     with open(xml_path, "w") as xml_file:
         xml_file.write("not valid xml :(")
     with self.assertRaises(ParseError):
         _try_parse(xml_path)
示例#2
0
 def test_try_parse_with_bad_file(self):
     """Should raise XMLSyntaxError: file exists but content is not valid."""
     xml_path = os.path.join(self.cwd, "test_try_parse.xml")
     self.tidy_file = xml_path
     with open(xml_path, "w") as xml_file:
         xml_file.write("not valid xml :(")
     with self.assertRaises(ParseError):
         _try_parse(xml_path)
示例#3
0
 def test_try_parse_with_path(self):
     """Should return root node from XML file path."""
     xml_path = os.path.join(self.cwd, "test_try_parse.xml")
     self.tidy_file = xml_path
     with open(xml_path, "w") as xml_file:
         xml_file.write(self.xml)
     root = _try_parse(xml_path)
     self.assertEqual("a", root.tag)
示例#4
0
 def test_try_parse_with_path(self):
     """Should return root node from XML file path."""
     xml_path = os.path.join(self.cwd, "test_try_parse.xml")
     self.tidy_file = xml_path
     with open(xml_path, "w") as xml_file:
         xml_file.write(self.xml)
     root = _try_parse(xml_path)
     self.assertEqual("a", root.tag)
示例#5
0
 def test_try_parse_with_bad_string(self):
     """Should raise IOError: string parse failed and its not a path."""
     with self.assertRaises(IOError):
         _try_parse("not valid xml :(")
示例#6
0
 def test_try_parse_with_bad_path(self):
     """Should raise IOError: file doesn't exist."""
     xml_path = os.path.join(self.cwd, "not_a_real_file.xyz")
     with self.assertRaises(IOError):
         _try_parse(xml_path)
示例#7
0
 def test_try_parse_with_string(self):
     """Should return root node from XML string."""
     root = _try_parse(self.xml)
     self.assertEqual("a", root.tag)
示例#8
0
 def test_try_parse_with_bad_string(self):
     """Should raise IOError: string parse failed and its not a path."""
     with self.assertRaises(IOError):
         _try_parse("not valid xml :(")
示例#9
0
 def test_try_parse_with_bad_path(self):
     """Should raise IOError: file doesn't exist."""
     xml_path = os.path.join(self.cwd, "not_a_real_file.xyz")
     with self.assertRaises(IOError):
         _try_parse(xml_path)
示例#10
0
 def test_try_parse_with_string(self):
     """Should return root node from XML string."""
     root = _try_parse(self.xml)
     self.assertEqual("a", root.tag)