Changeset 1773
- Timestamp:
- 09/24/08 16:16:22 (18 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/pylucid_project/tests/utils/unittest_addons.py
r1771 r1773 47 47 def __str__(self): 48 48 try: 49 msg = self.args[0]49 raw_msg = self.args[0] 50 50 51 51 """ 52 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' 53 "foo" != "bar" 54 'foo' != "bar" 55 "foo" != 'bar' 56 'foo' != 'bar' 57 With and without a 'u' ;) 57 58 """ 58 msg = msg.lstrip("u") # u"foobar" -> "foobar" 59 msg = raw_msg.lstrip("u") 60 59 61 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) 62 second_quote = msg[-1] 63 64 msg = msg.strip("'\"") 65 66 split_string = "%s != %s" % (first_quote, second_quote) 63 67 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 68 if split_string not in msg: 69 # Second part is unicode? 70 split_string = "%s != u%s" % (first_quote, second_quote) 77 71 72 if split_string not in msg: 73 msg = ( 74 "Split error output failed!" 75 " - split string >%r< not in message: %r" 76 ) % (split_string, raw_msg) 77 raise AssertionError(msg) 78 78 79 try: 79 80 block1, block2 = msg.split(split_string) … … 93 94 94 95 return ( 95 " \n\n---[Output:]---\n%s\n"96 "%r\n\n---[Output:]---\n%s\n" 96 97 "---[not equal to:]---\n%s" 97 98 "\n---[diff:]---\n%s" 98 ) % ( block1, block2, diff)99 ) % (raw_msg, block1, block2, diff) 99 100 except: 100 101 etype, value, tb = sys.exc_info()