Show
Ignore:
Timestamp:
09/22/08 15:40:45 (18 months ago)
Author:
JensDiemer
Message:

add macro function to creole markup

Location:
trunk/pylucid_project/tests
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/pylucid_project/tests/markup_creole.py

    r1769 r1771  
    5858        """ 
    5959        document = Parser(txt).parse() 
    60         out_string = HtmlEmitter(document).emit() 
     60        out_string = HtmlEmitter(document, verbose=1).emit() 
    6161        #print ">>>%r<<<" % out_string 
    6262        return out_string 
     
    138138        """) 
    139139             
    140  
    141  
    142140    def test_django1(self): 
    143141        """ 
     
    149147            The current page name: >{{ PAGE.name }}< great? 
    150148            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 %} 
    156152            A [[www.domain.tld|link]]. 
    157153            a {{/image.jpg|My Image}} image 
     
    162158            <p>The current page name: &gt;{{ PAGE.name }}&lt; great?<br /> 
    163159            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 %} 
    169163            <p>A <a href="www.domain.tld">link</a>.<br /> 
    170164            a <img src="/image.jpg" alt="My Image"> image</p> 
     
    172166            <p>no image: {{ foo|bar }}!<br /> 
    173167            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> 
    174225        """) 
    175226 
     
    477528            This is a normal Text block witch would 
    478529            escape html chars like < and > ;) 
     530             
     531            html code must start and end with a tag: 
    479532            <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 > 
    481544        """, """ 
    482545            <p>This is a normal Text block witch would<br /> 
    483546            escape html chars like &lt; and &gt; ;)</p> 
     547             
     548            <p>html code must start and end with a tag:</p> 
    484549            <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            &lt;p&gt;didn\'t&lt;br /&gt;<br /> 
     554            match&lt;/p&gt;</p> 
     555             
     556            <p>&lt;p&gt;<br /> 
     557                didn\'t match<br /> 
     558            &lt;/p&gt;</p> 
     559             
     560            <p>&lt;p&gt;didn\'t match,too.&lt; p &gt;</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>&lt;&lt;code&gt;&gt; 
     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> 
    486624        """) 
    487625 
  • trunk/pylucid_project/tests/utils/unittest_addons.py

    r1761 r1771  
    4848        try: 
    4949            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) 
    5063 
    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                 
    5778            try: 
    58                 block1, block2 = msg.split("' != '") 
    59             except ValueError: 
     79                block1, block2 = msg.split(split_string) 
     80            except ValueError, err: 
    6081                msg = self._format_output(msg) 
    6182                return ( 
    62                     "Format error in output\n" 
     83                    "Can't split error output: %r\n" 
    6384                    "Info:\n%s" 
    64                 ) % msg 
     85                ) % (err, msg) 
    6586 
    6687            #~ block1 = block1.rstrip("\\n")