Interested in buying ad space on this blog?
You can, on BuySellAds.com

Do you train Kung Fu?
Or know someone who does?
Then check out KungFuPeople.com
Mobile version of this page|
You searched for keyword:assertequal |
found 0 photos and 2 blogs in and 0 blog comments in 0.00 seconds |
Blogs |
|
|
|
String comparison function in Python (alpha) - 22nd of December 2007 I was working on a unittest which when it failed would say "this string != that string" and because some of these strings were very long (output of a HTML lib I wrote which spits out snippets of HTML code) it became hard to spot how they were different. So I decided to override the usual def assertEqualLongString(a, b):
NOT, POINT = '-', '*' if a != b: print a o = '' for i, e in enumerate(a): try: if e != b[i]: o += POINT else: o += NOT except IndexError: o += '*' o += NOT * (len(a)-len(o)) if len(b) > len(a): o += POINT* (len(b)-len(a)) print o print b raise AssertionError, '(see string comparison above)' |
|
|
To assert or assertEqual in Python unit testing - 14th of February 2009 When you write unit tests in Python you can use these widgets:
self.assertEqual(var1, var2, msg=None)
self.assertNotEqual(var1, var2, msg=None) self.assertTrue(expr, msg=None) self.assertRaises(exception, func, para, meters, ...) |

