Exemple #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')
Exemple #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
     )
Exemple #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'
     )
Exemple #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)
Exemple #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')
 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()
     )
Exemple #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'
     )
Exemple #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.')))
 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.')
         )
     )
Exemple #10
0
 def test_unicode(self):
     s = bold('Hello') + plain(' there ') + bold('folks')
     self.assertEquals(
         u'Hello there folks',
         unicode(s)
     )
Exemple #11
0
 def test_repr(self):
     s = bold('Hello') + plain(' there ') + bold('folks')
     self.assertEquals(
         "(bold)('Hello') + (plain)(' there ') + (bold)('folks')",
         repr(s)
     )
Exemple #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')
     )
 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)
Exemple #14
0
 def test_parse_pre_and_postfix_and_bold(self):
     self.assertEquals(
         parse_emphasis('pre**Hello**post'),
         plain('pre') + bold('Hello') + plain('post')
     )
Exemple #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'
     )
Exemple #16
0
 def test_eq(self):
     self.assertEquals(bold('Hello'), bold('Hello'))
     self.assertNotEquals(bold('Hello'), bold('Foo'))
     self.assertNotEquals(plain('Hello'), bold('Hello'))
Exemple #17
0
 def test_ne(self):
     self.assertFalse(bold('Hello') != bold('Hello'))
Exemple #18
0
 def test_parse_multiple_bold(self):
     self.assertEquals(
         parse_emphasis('x**Hello** **there**'),
         plain('x') + bold('Hello') + plain(' ') + bold('there')
     )
Exemple #19
0
 def test_bold_function_creates_bold_richstring(self):
     self.assertEquals(
         RichString(Segment('a', (Bold,))),
         bold('a')
     )
Exemple #20
0
 def test_parse_adjacent_bold(self):
     self.assertEquals(
         parse_emphasis('**123**456**'),
         bold('123') + plain('456**')
     )
Exemple #21
0
 def test_parse_bold(self):
     self.assertEquals(
         parse_emphasis('**Hello**'),
         bold('Hello')
     )
Exemple #22
0
 def test_italic_inside_bold(self):
     self.assertEquals(
         parse_emphasis('**Swedish *style* rules**'),
         bold('Swedish ') + (bold + italic)('style') + bold(' rules')
     )