Changeset 1771 for trunk/pylucid_project/tests/utils/unittest_addons.py
- Timestamp:
- 09/22/08 15:40:45 (18 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
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")