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

add macro function to creole markup

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • 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")