def test_get_value(self): ''' Verify xml.get_value ''' with tempfile.NamedTemporaryFile('w+', delete=False) as xml_file: xml_file.write(XML_STRING) xml_file.flush() xml_result = xml.get_value(xml_file.name, ".//actor[@id='2']") self.assertEqual(xml_result, "Liam Neeson") os.remove(xml_file.name)
def test_set_value(self): ''' Verify xml.set_value ''' with tempfile.NamedTemporaryFile('w+', delete=False) as xml_file: xml_file.write(XML_STRING) xml_file.flush() xml_result = xml.set_value(xml_file.name, ".//actor[@id='2']", "Patrick Stewart") assert xml_result is True xml_result = xml.get_value(xml_file.name, ".//actor[@id='2']") self.assertEqual(xml_result, "Patrick Stewart") os.remove(xml_file.name)