Problem with using unittest module

O

Olivier Langlois

Hi,

I have the following statement in my test :

self.assertRaises(CDKeyException, ValidationObject.Validate,
1001,'NonExistantKey')

and the test fails as if assertRaises was not catching the thrown
exception:

======================================================================
ERROR: test (DBLookupValidationTests.DBLookupValidationTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"C:\Dev\jade.r12sp\src\RVPackages\CDKey\Server\DBLookupValidationTests.py",
line 64, in test
self.assertRaises(CDKeyException, ValidationObject.Validate,
1001,'NonExistantKey')
File "C:\tools\Python\lib\unittest.py", line 320, in failUnlessRaises
callableObj(*args, **kwargs)
File
"C:\Dev\jade.r12sp\src/Services/local/Home\Scripts/system\CDKey\DBLookupValidation.py",
line 69, in Validate
raise CDKeyException, self.logger.error(e) CDKeyException

Any idea what is happening?

Thanks,
Olivier Langlois
http://www.olivierlanglois.net
 
P

Peter Otten

Olivier said:
I have the following statement in my test :

self.assertRaises(CDKeyException, ValidationObject.Validate,
1001,'NonExistantKey')

and the test fails as if assertRaises was not catching the thrown
exception:

======================================================================
ERROR: test (DBLookupValidationTests.DBLookupValidationTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"C \Dev\jade.r12sp\src\RVPackages\CDKey\Server\DBLookupValidationTests.py",
line 64, in test
self.assertRaises(CDKeyException, ValidationObject.Validate,
1001,'NonExistantKey')
File "C:\tools\Python\lib\unittest.py", line 320, in failUnlessRaises
callableObj(*args, **kwargs)
File
"C \Dev\jade.r12sp\src/Services/local/Home\Scripts/system\CDKey\DBLookupValidation.py",
line 69, in Validate
raise CDKeyException, self.logger.error(e) CDKeyException

Any idea what is happening?

Just a guess: you might have defined a CDKeyException twice...

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,967
Messages
2,570,148
Members
46,694
Latest member
LetaCadwal

Latest Threads

Top