Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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 :(")
Esempio n. 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)
Esempio n. 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)
Esempio n. 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 :(")
Esempio n. 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)
Esempio n. 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)