Problem with using unittest module

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Olivier Langlois

    #1

    Problem with using unittest module

    Hi,

    I have the following statement in my test :

    self.assertRais es(CDKeyExcepti on, ValidationObjec t.Validate,
    1001,'NonExista ntKey')

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

    =============== =============== =============== =============== ==========
    ERROR: test (DBLookupValida tionTests.DBLoo kupValidationTe sts)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
    File
    "C:\Dev\jade.r1 2sp\src\RVPacka ges\CDKey\Serve r\DBLookupValid ationTests.py",
    line 64, in test
    self.assertRais es(CDKeyExcepti on, ValidationObjec t.Validate,
    1001,'NonExista ntKey')
    File "C:\tools\Pytho n\lib\unittest. py", line 320, in failUnlessRaise s
    callableObj(*ar gs, **kwargs)
    File
    "C:\Dev\jade.r1 2sp\src/Services/local/Home\Scripts/system\CDKey\DB LookupValidatio n.py",
    line 69, in Validate
    raise CDKeyException, self.logger.err or(e) CDKeyException

    Any idea what is happening?

    Thanks,
    Olivier Langlois
    The main focus of this website is to present C++ Windows programming tutorials. Also as an hobby of mine, there is a dedicated section to fractals


  • Peter Otten

    #2
    Re: Problem with using unittest module

    Olivier Langlois wrote:
    I have the following statement in my test :
    >
    self.assertRais es(CDKeyExcepti on, ValidationObjec t.Validate,
    1001,'NonExista ntKey')
    >
    and the test fails as if assertRaises was not catching the thrown
    exception:
    >
    =============== =============== =============== =============== ==========
    ERROR: test (DBLookupValida tionTests.DBLoo kupValidationTe sts)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
    File
    "C
    \Dev\jade.r12sp \src\RVPackages \CDKey\Server\D BLookupValidati onTests.py",
    line 64, in test
    self.assertRais es(CDKeyExcepti on, ValidationObjec t.Validate,
    1001,'NonExista ntKey')
    File "C:\tools\Pytho n\lib\unittest. py", line 320, in failUnlessRaise s
    callableObj(*ar gs, **kwargs)
    File
    "C
    \Dev\jade.r12sp \src/Services/local/Home\Scripts/system\CDKey\DB LookupValidatio n.py",
    line 69, in Validate
    raise CDKeyException, self.logger.err or(e) CDKeyException
    >
    Any idea what is happening?
    Just a guess: you might have defined a CDKeyException twice...

    Peter

    Comment

    Working...