Changeset 1771 for trunk/pylucid_project/tests
- Timestamp:
- 09/22/08 15:40:45 (18 months ago)
- Location:
- trunk/pylucid_project/tests
- Files:
-
- 2 modified
-
markup_creole.py (modified) (6 diffs)
-
utils/unittest_addons.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pylucid_project/tests/markup_creole.py
r1769 r1771 58 58 """ 59 59 document = Parser(txt).parse() 60 out_string = HtmlEmitter(document ).emit()60 out_string = HtmlEmitter(document, verbose=1).emit() 61 61 #print ">>>%r<<<" % out_string 62 62 return out_string … … 138 138 """) 139 139 140 141 142 140 def test_django1(self): 143 141 """ … … 149 147 The current page name: >{{ PAGE.name }}< great? 150 148 A {% lucidTag page_update_list count=10 %} PyLucid plugin 151 {% sourcecode py %} 152 import sys 153 154 sys.stdout("Hello World!") 155 {% endsourcecode %} 149 {% block %} 150 FooBar 151 {% endblock %} 156 152 A [[www.domain.tld|link]]. 157 153 a {{/image.jpg|My Image}} image … … 162 158 <p>The current page name: >{{ PAGE.name }}< great?<br /> 163 159 A {% lucidTag page_update_list count=10 %} PyLucid plugin</p> 164 {% sourcecode py %} 165 import sys 166 167 sys.stdout("Hello World!") 168 {% endsourcecode %} 160 {% block %} 161 FooBar 162 {% endblock %} 169 163 <p>A <a href="www.domain.tld">link</a>.<br /> 170 164 a <img src="/image.jpg" alt="My Image"> image</p> … … 172 166 <p>no image: {{ foo|bar }}!<br /> 173 167 picture <a href="www.domain.tld"><img src="foo.JPG" alt="Foo"></a> as a link</p> 168 """) 169 170 def test_django2(self): 171 self.assertCreole(r""" 172 ==== Headline 1 173 174 On {% a tag 1 %} line 175 line two 176 177 ==== Headline 2 178 179 {% a tag 2 %} 180 181 Right block with a end tag: 182 {% block %} 183 <Foo:> {{ Bar }} 184 {% endblock %} 185 end block 186 187 A block without the right end block: 188 {% block1 %} 189 not matched 190 {% endblock2 %} 191 BBB 192 193 A block without endblock: 194 {% noblock3 %} 195 not matched 196 {% noblock3 %} 197 CCC 198 """, """ 199 <h4>Headline 1</h4> 200 201 <p>On {% a tag 1 %} line<br /> 202 line two</p> 203 204 <h4>Headline 2</h4> 205 206 {% a tag 2 %} 207 208 <p>Right block with a end tag:</p> 209 {% block %} 210 <Foo:> {{ Bar }} 211 {% endblock %} 212 <p>end block</p> 213 214 <p>A block without the right end block:<br /> 215 {% block1 %}<br /> 216 not matched<br /> 217 {% endblock2 %}<br /> 218 BBB</p> 219 220 <p>A block without endblock:<br /> 221 {% noblock3 %}<br /> 222 not matched<br /> 223 {% noblock3 %}<br /> 224 CCC</p> 174 225 """) 175 226 … … 477 528 This is a normal Text block witch would 478 529 escape html chars like < and > ;) 530 531 html code must start and end with a tag: 479 532 <p>this <strong class="my">html code</strong> line pass-through</p> 480 end 533 this works. 534 535 this: 536 <p>didn't<br /> 537 match</p> 538 539 <p> 540 didn't match 541 </p> 542 543 <p>didn't match,too.< p > 481 544 """, """ 482 545 <p>This is a normal Text block witch would<br /> 483 546 escape html chars like < and > ;)</p> 547 548 <p>html code must start and end with a tag:</p> 484 549 <p>this <strong class="my">html code</strong> line pass-through</p> 485 <p>end</p> 550 <p>this works.</p> 551 552 <p>this:<br /> 553 <p>didn\'t<br /><br /> 554 match</p></p> 555 556 <p><p><br /> 557 didn\'t match<br /> 558 </p></p> 559 560 <p><p>didn\'t match,too.< p ></p> 561 """) 562 563 def test_macro_html1(self): 564 self.assertCreole(r""" 565 <<a_not_existing_macro>> 566 567 <<code>> 568 some code 569 <</code>> 570 571 a macro: 572 <<code>> 573 <<code>> 574 the sourcecode 575 <</code>> 576 """, r""" 577 <p>[Error: Macro 'a_not_existing_macro' doesn't exist]</p> 578 <fieldset class="pygments_code"> 579 <legend class="pygments_code"><small title="no lexer matching the text found">unknown type</small></legend> 580 <pre><code>some code</code></pre> 581 </fieldset> 582 <p>a macro:</p> 583 <fieldset class="pygments_code"> 584 <legend class="pygments_code"><small title="no lexer matching the text found">unknown type</small></legend> 585 <pre><code><<code>> 586 the sourcecode</code></pre> 587 </fieldset> 588 """) 589 590 def test_macro_html2(self): 591 self.assertCreole(r""" 592 html macro: 593 <<html>> 594 <p><<this is 'html'>></p> 595 <</html>> 596 """, r""" 597 <p>html macro:</p> 598 <p><<this is 'html'>></p> 599 """) 600 601 def test_macro_pygments_code(self): 602 self.assertCreole(r""" 603 a macro: 604 <<code ext=.css>> 605 /* Stylesheet */ 606 form * { 607 vertical-align:middle; 608 } 609 <</code>> 610 the end 611 """, """ 612 <p>a macro:</p> 613 <fieldset class="pygments_code"> 614 <legend class="pygments_code">CSS</legend><table class="pygmentstable"><tr><td class="linenos"><pre>1 615 2 616 3 617 4</pre></td><td class="code"><div class="pygments"><pre><span class="c">/* Stylesheet */</span> 618 <span class="nt">form</span> <span class="o">*</span> <span class="p">{</span> 619 <span class="k">vertical-align</span><span class="o">:</span><span class="k">middle</span><span class="p">;</span> 620 <span class="p">}</span> 621 </pre></div> 622 </td></tr></table></fieldset> 623 <p>the end</p> 486 624 """) 487 625 -
trunk/pylucid_project/tests/utils/unittest_addons.py
r1761 r1771 48 48 try: 49 49 msg = self.args[0] 50 51 """ 52 Get the right split_string is not easy. There are three kinds: 53 u"foo" != "bar" 54 u'foo' != "bar" 55 u"foo" != 'bar' 56 u'foo' != 'bar' 57 """ 58 msg = msg.lstrip("u") # u"foobar" -> "foobar" 59 first_quote = msg[0] 60 last_quote = msg[-1] 61 split_string = "%s != %s" % (first_quote, last_quote) 62 msg = msg.strip(first_quote + last_quote) 50 63 51 # strip ' out 52 if msg.startswith("u'"): 53 msg = msg[2:-1] 54 else: 55 msg = msg[1:-1] 56 64 # # strip ' out 65 # if msg.startswith("u'"): 66 # msg = msg[2:-1] 67 # else: 68 # msg = msg[1:-1] 69 # 70 # if "' != '" in msg: 71 # split_string = "' != '" 72 # elif '" != "' in msg: 73 # split_string = '" != "' 74 # else: 75 # msg = self._format_output(msg) 76 # return "Unknwon error output: %r" % msg 77 57 78 try: 58 block1, block2 = msg.split( "' != '")59 except ValueError :79 block1, block2 = msg.split(split_string) 80 except ValueError, err: 60 81 msg = self._format_output(msg) 61 82 return ( 62 " Format error in output\n"83 "Can't split error output: %r\n" 63 84 "Info:\n%s" 64 ) % msg85 ) % (err, msg) 65 86 66 87 #~ block1 = block1.rstrip("\\n")