Exemplo n.º 1
0
 def test_several_styles(self):
     rich = bold('outer') + (bold + italic)('inner') + bold('outer')
     write_text(self.out, rich, False)
     self.assertEqual(
         self.out.getvalue(), '      <Text Style="Bold">outer</Text>\n'
         '      <Text Style="Bold+Italic">inner</Text>\n'
         '      <Text Style="Bold">outer</Text>\n')
Exemplo n.º 2
0
 def test_write_text_adds_line_break_if_requested(self):
     rich = bold('outer') + (bold + italic)('inner') + bold('outer')
     write_text(self.out, rich, True)
     self.assertEqual(
         self.out.getvalue(),
         '      <Text Style="Bold">outer</Text>\n'
         '      <Text Style="Bold+Italic">inner</Text>\n'
         '      <Text Style="Bold">outer\n</Text>\n'  # note newline
     )
Exemplo n.º 3
0
 def test_several_styles(self):
     rich = bold('outer') + (bold + italic)('inner') + bold('outer')
     write_text(self.out, rich, False)
     self.assertEqual(
         self.out.getvalue(),
         '      <Text Style="Bold">outer</Text>\n'
         '      <Text Style="Bold+Italic">inner</Text>\n'
         '      <Text Style="Bold">outer</Text>\n'
     )
Exemplo n.º 4
0
 def test_concatenating_two_richstrings(self):
     expected = RichString(Segment('hello', ()),
                           Segment(' there', (Bold, )))
     s1 = plain('hello')
     s2 = bold(' there')
     result = s1 + s2
     self.assertEquals(expected, result)
Exemplo n.º 5
0
 def test_sequential_styles(self):
     rich = plain('plain') + bold('b') + italic('i')
     write_text(self.out, rich, False)
     self.assertEqual(
         self.out.getvalue(), '      <Text>plain</Text>\n'
         '      <Text Style="Bold">b</Text>\n'
         '      <Text Style="Italic">i</Text>\n')
Exemplo n.º 6
0
 def test_to_html(self):
     s = (
         bold('bold') + plain(' normal ') +
         italic('italic') + underline('wonderline')
     )
     self.assertEquals(
         '<strong>bold</strong> normal <em>italic</em><u>wonderline</u>',
         s.to_html()
     )
Exemplo n.º 7
0
 def test_sequential_styles(self):
     rich = plain('plain') + bold('b') + italic('i')
     write_text(self.out, rich, False)
     self.assertEqual(
         self.out.getvalue(),
         '      <Text>plain</Text>\n'
         '      <Text Style="Bold">b</Text>\n'
         '      <Text Style="Italic">i</Text>\n'
     )
Exemplo n.º 8
0
 def test_complicated(self):
     # As reported by Stu
     self.assertEquals(
         parse_emphasis(
             'You can _underline_ words, make them **bold** or *italic* '
             'or even ***bold italic.***'),
         (plain('You can ') + underline('underline') +
          plain(' words, make them ') + bold('bold') + plain(' or ') +
          italic('italic') + plain(' or even ') +
          (bold + italic)('bold italic.')))
Exemplo n.º 9
0
 def test_complicated(self):
     # As reported by Stu
     self.assertEquals(
         parse_emphasis(
             'You can _underline_ words, make them **bold** or *italic* '
             'or even ***bold italic.***'
         ), (
             plain('You can ') + underline('underline') +
             plain(' words, make them ') + bold('bold') + plain(' or ') +
             italic('italic') + plain(' or even ') +
             (bold + italic)('bold italic.')
         )
     )
Exemplo n.º 10
0
 def test_unicode(self):
     s = bold('Hello') + plain(' there ') + bold('folks')
     self.assertEquals(
         u'Hello there folks',
         unicode(s)
     )
Exemplo n.º 11
0
 def test_repr(self):
     s = bold('Hello') + plain(' there ') + bold('folks')
     self.assertEquals(
         "(bold)('Hello') + (plain)(' there ') + (bold)('folks')",
         repr(s)
     )
Exemplo n.º 12
0
 def test_two_bold_should_not_create_one_long_bold_string(self):
     self.assertEquals(
         parse_emphasis('**first** **second**'),
         bold('first') + plain(' ') + bold('second')
     )
Exemplo n.º 13
0
 def test_concatenating_two_richstrings(self):
     expected = RichString(Segment('hello', ()), Segment(' there', (Bold,)))
     s1 = plain('hello')
     s2 = bold(' there')
     result = s1 + s2
     self.assertEquals(expected, result)
Exemplo n.º 14
0
 def test_parse_pre_and_postfix_and_bold(self):
     self.assertEquals(
         parse_emphasis('pre**Hello**post'),
         plain('pre') + bold('Hello') + plain('post')
     )
Exemplo n.º 15
0
 def test_bold_text_should_have_bold_style(self):
     write_text(self.out, bold('hello'), False)
     self.assertEqual(
         self.out.getvalue(),
         '      <Text Style="Bold">hello</Text>\n'
     )
Exemplo n.º 16
0
 def test_eq(self):
     self.assertEquals(bold('Hello'), bold('Hello'))
     self.assertNotEquals(bold('Hello'), bold('Foo'))
     self.assertNotEquals(plain('Hello'), bold('Hello'))
Exemplo n.º 17
0
 def test_ne(self):
     self.assertFalse(bold('Hello') != bold('Hello'))
Exemplo n.º 18
0
 def test_parse_multiple_bold(self):
     self.assertEquals(
         parse_emphasis('x**Hello** **there**'),
         plain('x') + bold('Hello') + plain(' ') + bold('there')
     )
Exemplo n.º 19
0
 def test_bold_function_creates_bold_richstring(self):
     self.assertEquals(
         RichString(Segment('a', (Bold,))),
         bold('a')
     )
Exemplo n.º 20
0
 def test_parse_adjacent_bold(self):
     self.assertEquals(
         parse_emphasis('**123**456**'),
         bold('123') + plain('456**')
     )
Exemplo n.º 21
0
 def test_parse_bold(self):
     self.assertEquals(
         parse_emphasis('**Hello**'),
         bold('Hello')
     )
Exemplo n.º 22
0
 def test_italic_inside_bold(self):
     self.assertEquals(
         parse_emphasis('**Swedish *style* rules**'),
         bold('Swedish ') + (bold + italic)('style') + bold(' rules')
     )