def testBadParser(self): self.fill_file(".xml", """<?xml version="1.0"?> <foo><bar>baz</bar></foo> """) # the generated file is not claimed f = open(self.filename) assert XmlParser.claims_for_parse(f) > 0 f.close() self.assertRaises(ParserError, Package, self.filename)
def testForceParser(self): self.fill_file(".foo", """<?xml version="1.0"?> <foo><bar>baz</bar></foo> """) # the generated file is not claimed f = open(self.filename) assert XmlParser.claims_for_parse(f) == 0 assert ZipParser.claims_for_parse(f) == 0 f.close() self.assertRaises(NoClaimingError, Package, self.filename) self.assertRaises(ParserError, Package, self.filename, parser=XmlParser) self.assertRaises(BadZipfile, Package, self.filename, parser=ZipParser)
def __init__(self, file_, package): _AdveneXmlParser.__init__(self, file_, package)