def testConsistency(self): '''Tests if the data is consistent with the content type (when RDF or JSON)''' # When the content type is application/json, try parsing the data as JSON if ct == 'application/json': try: json.loads(data) except: self.fail("HTTP content-type is 'application/json' but JSON parsing failed") # When the content type is application/rdf+xml, try parsing the data as RDF if ct == 'application/rdf+xml': try: parse_rdf(data) except: self.fail("HTTP content-type is 'application/rdf+xml' but RDF-XML parsing failed")
def setUp(self): '''General tests setup (parses the RDF string in the global data var)''' try: self.rdf = parse_rdf(data) self.failed = False except: self.rdf = None self.failed = True