# HG changeset patch # User Frederic Bastien # Date 1212774257 14400 # Node ID 29f394813c3c6ddf5ac7b8ff11604297223c5169 # Parent b39327d5506fcfecf57a27d4bb43f5965dc42f6b use the unittest function to test that execption is raised diff -r b39327d5506f -r 29f394813c3c _test_lookup_list.py --- a/_test_lookup_list.py Fri Jun 06 13:34:25 2008 -0400 +++ b/_test_lookup_list.py Fri Jun 06 13:44:17 2008 -0400 @@ -1,20 +1,5 @@ from lookup_list import * import unittest -def have_raised(to_eval, **var): - have_thrown = False - try: - eval(to_eval) - except : - have_thrown = True - return have_thrown - -def have_raised2(f, *args, **kwargs): - have_thrown = False - try: - f(*args, **kwargs) - except : - have_thrown = True - return have_thrown class T_LookUpList(unittest.TestCase): def test_LookupList(self): @@ -32,8 +17,7 @@ example2 = LookupList(['v','w'], ['a','b']) example3 = LookupList(['x','y','z','u','v','w'], [[1, 2, 3],2,3,0,'a','b']) assert example+example2==example3 - assert have_raised("var['x']+var['x']",x=example) - + self.assertRaises(AssertionError,example.__add__,example) del example, example2, example3, x, y ,z if __name__=='__main__':