473,395 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Problem with using unittest module

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\DBL ookupValidationTests.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

Jul 31 '06 #1
1 1359
Olivier Langlois wrote:
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\DBLook upValidationTests.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
Jul 31 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Will Stuyvesant | last post by:
I have a unittest testfile like this: ----------------------- test_mod.py --------------------- import sys sys.path.append('..') import unittest import mod class...
0
by: Danny Shevitz | last post by:
Why doesn't the following code snippet work? The error is ImportError: No module named myTestCase2 TIA, Danny %<--------------------------------------------------------------------
8
by: Steve Erickson | last post by:
I have a logger class that uses the Python logging module. When I call it within a program using the unittest module, I get one line in the log file for the first test, two identical ones for the...
3
by: Qiangning Hong | last post by:
I want to apply TDD (test driven development) on my project. I am working on a class like this (in plan): # file: myclass.py import _extmod class MyClass(object): def __init__(self):...
41
by: Roy Smith | last post by:
I've used the standard unittest (pyunit) module on a few projects in the past and have always thought it basicly worked fine but was just a little too complicated for what it did. I'm starting a...
7
by: Jorgen Grahn | last post by:
I have a set of tests in different modules: test_foo.py, test_bar.py and so on. All of these use the simplest possible internal layout: a number of classes containing test*() methods, and the good...
18
by: Scott David Daniels | last post by:
There has been a bit of discussion about a way of providing test cases in a test suite that _should_ work but don't. One of the rules has been the test suite should be runnable and silent at every...
1
by: Chris Fonnesbeck | last post by:
I have a module for which I am trying to code a unit test. However, when I run unittest.main(), I get: In : import PyMC In : PyMC.unittest.main() ...
2
by: chrisber | last post by:
using the unittest module in Python 2.3.5, I've written some test code that ends up with if __name__ == "__main__": unittest.main() Since I want to run this code in various environments, I'd...
3
by: Paul Moore | last post by:
My normal testing consists of a tests.py script using unittest, with the basic if __name__ == '__main__': unittest.main() incantation to get things going. But I now want to incorporate...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.