Ejemplo n.º 1
0
 def test_simplespan(self):
     input = HTMLParser(StringIO("<span>test</span>"))
     lines = list(_group_lines(input))
     self.assertEquals(len(lines), 1)
     self.assertTrue(isinstance(lines[0], Stream))
     for (a, b) in zip(lines[0], input):
         self.assertEqual(a, b)
Ejemplo n.º 2
0
 def test_simplespan(self):
     input = HTMLParser(StringIO(u"<span>test</span>"), encoding=None)
     lines = list(_group_lines(input))
     self.assertEqual(len(lines), 1)
     self.assertIsInstance(lines[0], Stream)
     for (a, b) in zip(lines[0], input):
         self.assertEqual(a, b)
Ejemplo n.º 3
0
 def test_simplespan(self):
     input = HTMLParser(StringIO(u"<span>test</span>"), encoding=None)
     lines = list(_group_lines(input))
     self.assertEqual(len(lines), 1)
     self.assertIsInstance(lines[0], Stream)
     for (a, b) in zip(lines[0], input):
         self.assertEqual(a, b)
Ejemplo n.º 4
0
 def test_empty_text_stream(self):
     """
     http://trac.edgewall.org/ticket/4336
     """
     input = [(TEXT, "", (None, -1, -1))]
     lines = list(_group_lines(input))
     self.assertEquals(len(lines), 0)
Ejemplo n.º 5
0
 def test_empty_text_stream(self):
     """
     http://trac.edgewall.org/ticket/4336
     """
     input = [(TEXT, "", (None, -1, -1))]
     lines = list(_group_lines(input))
     self.assertEqual(len(lines), 0)
Ejemplo n.º 6
0
 def test_empty_text_in_span(self):
     """
     http://trac.edgewall.org/ticket/4336
     """
     ns = Namespace('http://www.w3.org/1999/xhtml')
     input = [(START, (ns.span, Attrs([])), (None, -1, -1)),
              (TEXT, "", (None, -1, -1)),
              (END, ns.span, (None, -1, -1)),
             ]
     lines = list(_group_lines(input))
     self.assertEqual(len(lines), 0)
Ejemplo n.º 7
0
 def test_newline2(self):
     """
     Same as test_newline above, but make sure it behaves properly wrt
     the trailing \\n, especially given it's inside an element.
     """
     input = HTMLParser(StringIO('<span class="c">a\nb\n</span>'))
     expected = ['<span class="c">a</span>',
                 '<span class="c">b</span>',
                ]
     lines = list(_group_lines(input))
     self.assertEquals(len(lines), len(expected))
     for a, b in zip(lines, expected):
         self.assertEquals(a.render('html'), b)
Ejemplo n.º 8
0
 def test_newline(self):
     """
     If the text element does not end with a newline, it's not properly
     closed.
     """
     input = HTMLParser(StringIO('<span class="c">a\nb</span>'))
     expected = ['<span class="c">a</span>',
                 '<span class="c">b</span>',
                ]
     lines = list(_group_lines(input))
     self.assertEquals(len(lines), len(expected))
     for a, b in zip(lines, expected):
         self.assertEquals(a.render('html'), b)
Ejemplo n.º 9
0
 def test_multinewline(self):
     """
     ditto.
     """
     input = HTMLParser(StringIO('<span class="c">\n\n\na</span>'))
     expected = ['<span class="c"></span>',
                 '<span class="c"></span>',
                 '<span class="c"></span>',
                 '<span class="c">a</span>',
                ]
     lines = list(_group_lines(input))
     self.assertEquals(len(lines), len(expected))
     for a, b in zip(lines, expected):
         self.assertEquals(a.render('html'), b)
Ejemplo n.º 10
0
 def test_text_only_stream2(self):
     input = [(TEXT, "test\n", (None, -1, -1))]
     lines = list(_group_lines(input))
     self.assertEqual(len(lines), 1)
     self.assertIsInstance(lines[0], Stream)
     self.assertEqual(lines[0].events, [(TEXT, "test", (None, -1, -1))])
Ejemplo n.º 11
0
 def test_empty_stream(self):
     # FIXME: this currently fails
     lines = list(_group_lines([]))
     self.assertEqual(len(lines), 0)
Ejemplo n.º 12
0
 def test_newline_stream2(self):
     input = [(TEXT, "\n\n\n", (None, -1, -1))]
     lines = list(_group_lines(input))
     self.assertEquals(len(lines), 3)
Ejemplo n.º 13
0
 def test_text_only_stream2(self):
     input = [(TEXT, "test\n", (None, -1, -1))]
     lines = list(_group_lines(input))
     self.assertEquals(len(lines), 1)
     self.assertTrue(isinstance(lines[0], Stream))
     self.assertEquals(lines[0].events, [(TEXT, "test", (None, -1, -1))])
Ejemplo n.º 14
0
 def test_text_only_stream(self):
     input = [(TEXT, "test", (None, -1, -1))]
     lines = list(_group_lines(input))
     self.assertEquals(len(lines), 1)
     self.assertTrue(isinstance(lines[0], Stream))
     self.assertEquals(lines[0].events, input)
Ejemplo n.º 15
0
 def test_empty_stream(self):
     # FIXME: this currently fails
     lines = list(_group_lines([]))
     self.assertEqual(len(lines), 0)
Ejemplo n.º 16
0
 def test_newline_stream2(self):
     input = [(TEXT, "\n\n\n", (None, -1, -1))]
     lines = list(_group_lines(input))
     self.assertEqual(len(lines), 3)
Ejemplo n.º 17
0
 def test_text_only_stream(self):
     input = [(TEXT, "test", (None, -1, -1))]
     lines = list(_group_lines(input))
     self.assertEqual(len(lines), 1)
     self.assertIsInstance(lines[0], Stream)
     self.assertEqual(lines[0].events, input)