Пример #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)