Mercurial > pylearn
changeset 281:29f394813c3c
use the unittest function to test that execption is raised
author | Frederic Bastien <bastienf@iro.umontreal.ca> |
---|---|
date | Fri, 06 Jun 2008 13:44:17 -0400 |
parents | b39327d5506f |
children | b55c829695f1 |
files | _test_lookup_list.py |
diffstat | 1 files changed, 1 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- 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__':