Пример #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"))
Пример #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=""))
Пример #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=""
                             ))
Пример #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'
         }))
Пример #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"
                             ))
Пример #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'}))
Пример #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'
             }))
Пример #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))
Пример #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))
Пример #10
0
 def test_expand_1(self):
     "Empty dict + empty strings"
     d = {}
     s = u''
     expected = u''
     self.assertEqual(expected, expand(s, d))
Пример #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'}))
Пример #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'}))
Пример #13
0
 def test_expand_3(self):
     "Simple replacement"
     self.assertEqual('An apple',
                      expand('An {apple_fruit}', {'apple_fruit': 'apple'}))
Пример #14
0
 def test_expand_1(self):
     "Empty dict + empty strings"
     d = {}
     s = u''
     expected = u''
     self.assertEqual(expected, expand(s, d))
Пример #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))
Пример #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))
Пример #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))
Пример #18
0
 def test_expand_3(self):
     "Simple replacement"
     self.assertEqual('An apple',
                      expand('An {apple_fruit}',
                             {'apple_fruit': 'apple'}))
Пример #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))
Пример #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'}))
Пример #21
0
 def test_expand_2(self):
     "Empty dict"
     d = {}
     s = u'xx{}xx'
     expected = u'xx{}xx'
     self.assertEqual(expected, expand(s, d))
Пример #22
0
 def test_expand_2(self):
     "Empty dict"
     d = {}
     s = u'xx{}xx'
     expected = u'xx{}xx'
     self.assertEqual(expected, expand(s, d))