Ejemplo n.º 1
0
 def test_expand_7(self):
     "Replacement with different tag and default attribute"
     self.assertEqual(
         'A <span class="green">Apple</span>',
         expand('A {apple_fruit|Apple}', {'apple_fruit': 'green'},
                tag="span",
                default_attribute="class"))
Ejemplo n.º 2
0
 def test_expand_11(self):
     "Replacement with different tag and empty default attribute"
     self.assertEqual(
         'A <strong>Apple</strong>',
         expand('A {apple_fruit|Apple}', {'apple_fruit': 'green'},
                tag="strong",
                default_attribute=""))
Ejemplo n.º 3
0
 def test_expand_11(self):
     "Replacement with different tag and empty default attribute"
     self.assertEqual('A <strong>Apple</strong>',
                      expand('A {apple_fruit|Apple}',
                             {'apple_fruit': 'green'},
                             tag="strong",
                             default_attribute=""
                             ))
Ejemplo n.º 4
0
 def test_expand_5(self):
     "Replacement with link description evaluation"
     self.assertEqual(
         'A <a href="http://www.apple.com">pear</a>',
         expand('A {apple_fruit|apple}', {
             'apple_fruit': 'http://www.apple.com',
             'apple': 'pear'
         }))
Ejemplo n.º 5
0
 def test_expand_7(self):
     "Replacement with different tag and default attribute"
     self.assertEqual('A <span class="green">Apple</span>',
                      expand('A {apple_fruit|Apple}',
                             {'apple_fruit': 'green'},
                             tag="span",
                             default_attribute="class"
                             ))
Ejemplo n.º 6
0
 def test_expand_6(self):
     "Replacement with link description evaluation and hash argument"
     self.assertEqual(
         'A <a href="http://www.apple.com" target="_blank">pear</a>',
         expand('A {apple_fruit|apple}',
                {'apple_fruit': {'href': 'http://www.apple.com',
                                 'target': '_blank'},
                 'apple': 'pear'}))
Ejemplo n.º 7
0
 def test_expand_6(self):
     "Replacement with link description evaluation and hash argument"
     self.assertEqual(
         'A <a href="http://www.apple.com" target="_blank">pear</a>',
         expand(
             'A {apple_fruit|apple}', {
                 'apple_fruit': {
                     'href': 'http://www.apple.com',
                     'target': '_blank'
                 },
                 'apple': 'pear'
             }))
Ejemplo n.º 8
0
 def test_expand_10(self):
     "Double replacement with link and special chars in attribute value"
     d = {
         "url": {
             'href': 'http://picard?id=test',
             'class': 'ext',
             'title': 'title with <€àùîé> "" l\'a in it',
         }
     }
     s = u'xx{url|Picard1}xxxx{url|Picard2}xx'
     expected = 'xx<a class="ext" href="http://picard?id=test" title="title with &lt;&#8364;&#224;&#249;&#238;&#233;&gt; &quot;&quot; l&#x27;a in it">Picard1</a>xxxx<a class="ext" href="http://picard?id=test" title="title with &lt;&#8364;&#224;&#249;&#238;&#233;&gt; &quot;&quot; l&#x27;a in it">Picard2</a>xx'
     self.assertEqual(expected, expand(s, d))
Ejemplo n.º 9
0
 def test_expand_10(self):
     "Double replacement with link and special chars in attribute value"
     d = {
         "url": {
             'href': 'http://picard?id=test',
             'class': 'ext',
             'title': 'title with <€àùîé> "" l\'a in it',
         }
     }
     s = u'xx{url|Picard1}xxxx{url|Picard2}xx'
     expected = 'xx<a class="ext" href="http://picard?id=test" title="title with &lt;&#8364;&#224;&#249;&#238;&#233;&gt; &quot;&quot; l&#x27;a in it">Picard1</a>xxxx<a class="ext" href="http://picard?id=test" title="title with &lt;&#8364;&#224;&#249;&#238;&#233;&gt; &quot;&quot; l&#x27;a in it">Picard2</a>xx'
     self.assertEqual(expected, expand(s, d))
Ejemplo n.º 10
0
 def test_expand_1(self):
     "Empty dict + empty strings"
     d = {}
     s = u''
     expected = u''
     self.assertEqual(expected, expand(s, d))
Ejemplo n.º 11
0
 def test_expand_4(self):
     "Replacement with link"
     self.assertEqual('An <a href="http://www.apple.com">Apple</a>',
                      expand('An {apple_fruit|Apple}',
                             {'apple_fruit': 'http://www.apple.com'}))
Ejemplo n.º 12
0
 def test_expand_4(self):
     "Replacement with link"
     self.assertEqual(
         'An <a href="http://www.apple.com">Apple</a>',
         expand('An {apple_fruit|Apple}',
                {'apple_fruit': 'http://www.apple.com'}))
Ejemplo n.º 13
0
 def test_expand_3(self):
     "Simple replacement"
     self.assertEqual('An apple',
                      expand('An {apple_fruit}', {'apple_fruit': 'apple'}))
Ejemplo n.º 14
0
 def test_expand_1(self):
     "Empty dict + empty strings"
     d = {}
     s = u''
     expected = u''
     self.assertEqual(expected, expand(s, d))
Ejemplo n.º 15
0
 def test_expand_9(self):
     "Replacement of { and }"
     d = {"{": "YES", '}': "NO"}
     s = u'xx{{}{}}xx'
     expected = u'xxYESNOxx'
     self.assertEqual(expected, expand(s, d))
Ejemplo n.º 16
0
 def test_expand_8(self):
     "Replacement of empty string by a single word"
     d = {"": "YES"}
     s = u'xx{}xx'
     expected = u'xxYESxx'
     self.assertEqual(expected, expand(s, d))
Ejemplo n.º 17
0
 def test_expand_8(self):
     "Replacement of empty string by a single word"
     d = {"": "YES"}
     s = u'xx{}xx'
     expected = u'xxYESxx'
     self.assertEqual(expected, expand(s, d))
Ejemplo n.º 18
0
 def test_expand_3(self):
     "Simple replacement"
     self.assertEqual('An apple',
                      expand('An {apple_fruit}',
                             {'apple_fruit': 'apple'}))
Ejemplo n.º 19
0
 def test_expand_9(self):
     "Replacement of { and }"
     d = {"{": "YES", '}': "NO"}
     s = u'xx{{}{}}xx'
     expected = u'xxYESNOxx'
     self.assertEqual(expected, expand(s, d))
Ejemplo n.º 20
0
 def test_expand_5(self):
     "Replacement with link description evaluation"
     self.assertEqual('A <a href="http://www.apple.com">pear</a>',
                      expand('A {apple_fruit|apple}',
                             {'apple_fruit': 'http://www.apple.com',
                              'apple': 'pear'}))
Ejemplo n.º 21
0
 def test_expand_2(self):
     "Empty dict"
     d = {}
     s = u'xx{}xx'
     expected = u'xx{}xx'
     self.assertEqual(expected, expand(s, d))
Ejemplo n.º 22
0
 def test_expand_2(self):
     "Empty dict"
     d = {}
     s = u'xx{}xx'
     expected = u'xx{}xx'
     self.assertEqual(expected, expand(s, d))