def transformIterable(self, result, encoding): try: parser = SnippetParser() except AttributeError: return result if self.request['PATH_INFO'].endswith('edit'): return result contentType = self.request.response.getHeader('Content-Type') if contentType is None or not contentType.startswith('text/html'): return None ce = self.request.response.getHeader('Content-Encoding') if ce and ce in ('zip', 'deflate', 'compress'): return None try: if result == ['']: return None result = getHTMLSerializer(result, pretty_print=False) except (TypeError): return None return [ parser.parsePage(r) for r in result ]
def test_inner_span(self): sp = SnippetParser() text = sp.parsePage(self.innerSpan) correct = "This is a <span style=\"text-decoration: blink;\">stupid</span> test! Or is it?" self.assertTrue( text != '' ) self.assertEqual(text, correct)
def test_multiple_different(self): sp = SnippetParser() text = sp.parsePage(self.differentPlugs) correct = "This is a <span style=\"text-decoration: blink;\">stupid</span> test! Or is it meaningless?" self.assertTrue( text != '' ) self.assertEqual(text, correct)
def test_benign_span(self): sp = SnippetParser() text = sp.parsePage(self.benignSpan) correct = "This is a <span style=\"text-decoration: blink;\">meaningless test!</span> Or is it?" self.assertTrue( text != '' ) self.assertEqual(text, correct)
def test_multiple_ids(self): sp = SnippetParser() text = sp.parsePage(self.testMultiple) correct = "This is a meaningless test! Or is it meaningless?" self.assertTrue( text != '' ) self.assertEqual(text, correct)
def test_dead_ids(self): sp = SnippetParser() text = sp.parsePage(self.testDeadSnippet) correct = "This is a test! Or is it?" self.assertTrue( text != '' ) self.assertEqual(text, correct)
def test_single(self): sp = SnippetParser() text = sp.parsePage(self.testSingle) correct = "This is a meaningless test! Or is it?" self.assertTrue( text != '' ) self.assertEqual(text, correct)
def test_normal(self): sp = SnippetParser() text = sp.parsePage(self.normalString) correct = "This is a test! Or is it?" self.assertTrue( text != '' ) self.assertEqual(text, correct)