def _ElementToString(root): """Returns the node as an XML string. Args: root: The ElementTree.Element instance. Returns: The XML string. """ output = StringIO() ET.ElementTree(root).write(output, 'utf-8') return output.getvalue()
def testBadEolContext(self): """Make sure the filename is included in the report of a bad eol.""" filename = "routes.txt" old_zip = zipfile.ZipFile( self.GetPath('tests', 'data', 'good_feed.zip'), 'r') content_dict = self.ConvertZipToDict(old_zip) old_routes = content_dict[filename] new_routes = old_routes.replace('\n', '\r\n', 1) self.assertNotEquals(old_routes, new_routes) content_dict[filename] = new_routes new_zipfile_mem = self.ConvertDictToZip(content_dict) options = MockOptions() output_file = StringIO() feedvalidator.RunValidationOutputToFile( new_zipfile_mem, options, output_file) self.assertMatchesRegex(filename, output_file.getvalue())