コード例 #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)
コード例 #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)
コード例 #3
0
ファイル: api.py プロジェクト: exocad/exotrac
 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)
コード例 #4
0
ファイル: api.py プロジェクト: wiraqutra/photrackjp
 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)
コード例 #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)
コード例 #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)
コード例 #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)
コード例 #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)
コード例 #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)
コード例 #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))])
コード例 #11
0
 def test_empty_stream(self):
     # FIXME: this currently fails
     lines = list(_group_lines([]))
     self.assertEqual(len(lines), 0)
コード例 #12
0
ファイル: api.py プロジェクト: wiraqutra/photrackjp
 def test_newline_stream2(self):
     input = [(TEXT, "\n\n\n", (None, -1, -1))]
     lines = list(_group_lines(input))
     self.assertEquals(len(lines), 3)
コード例 #13
0
ファイル: api.py プロジェクト: wiraqutra/photrackjp
 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))])
コード例 #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)
コード例 #15
0
ファイル: api.py プロジェクト: wiraqutra/photrackjp
 def test_empty_stream(self):
     # FIXME: this currently fails
     lines = list(_group_lines([]))
     self.assertEqual(len(lines), 0)
コード例 #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)
コード例 #17
0
ファイル: api.py プロジェクト: exocad/exotrac
 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)