473,574 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

unit testing failure makes no sense

I have some unit testing code in one of my modules that appears to
run without an error, but the unit test fails anyhow. Have a look at
the output below -- the TestResult seems to have no errors and no
failures, yet I get a system exit.

------------------------------------------------------------------------
---
exceptions.Syst emExit Traceback (most
recent call last)

/Users/chris/<ipython console>

/Library/Frameworks/Python.framewor k/Versions/2.4/lib/python2.4/
unittest.py in __init__(self=< unittest.TestPr ogram object at
0x10ee670>, module='__main_ _', defaultTest=Non e, argv=['/usr/local/
bin/ipython'], testRunner=None , testLoader=<uni ttest.TestLoade r
object at 0x606290>)
757 self.progName = os.path.basenam e(argv[0])
758 self.parseArgs( argv)
--759 self.runTests()
self.runTests = <bound method TestProgram.run Tests of
<unittest.TestP rogram object at 0x10ee670>>
760
761 def usageExit(self, msg=None):

/Library/Frameworks/Python.framewor k/Versions/2.4/lib/python2.4/
unittest.py in runTests(self=< unittest.TestPr ogram object at 0x10ee670>)
795 self.testRunner = TextTestRunner
(verbosity=self .verbosity)
796 result = self.testRunner .run(self.test)
--797 sys.exit(not result.wasSucce ssful())
global sys.exit = <built-in function exit>
result.wasSucce ssful = <bound method
_TextTestResult .wasSuccessful of <unittest._Text TestResult run=3
errors=0 failures=0>>
798
799 main = TestProgram

SystemExit: False
Type exit or quit to exit IPython (%Exit or %Quit do so
unconditionally ).

Any ideas what is going wrong here? Here is my testing code:

class MCMCTest(unitte st.TestCase):

def testCoalMiningD isasters(self):
"""Run coal mining disasters example sampler"""

print 'Running coal mining disasters test case ...'

# Create an instance of the sampler
self.sampler = DisasterSampler ()

# Specify the nimber of iterations to execute
iterations = 10000
thin = 2
burn = 5000
chains = 2

# Run MCMC simulation
for i in range(chains):

self.failUnless (self.sampler.s ample(iteration s,
burn=burn, thin=thin, plot=True))

# Run convergence diagnostics
self.sampler.co nvergence()

# Plot autocorrelation
self.sampler.au tocorrelation()

# Goodness of fit
x, n = self.sampler.go odness(iteratio ns/10)['overall']
self.failIf(x/n < 0.05 or x/n 0.95)
--
Christopher Fonnesbeck
+ Atlanta, GA
+ fonnesbeck at mac.com
+ Contact me on AOL IM using email address
Aug 30 '06 #1
1 1813
li*******@mac.c om wrote:
I have some unit testing code in one of my modules that appears to
run without an error, but the unit test fails anyhow. Have a look at
the output below -- the TestResult seems to have no errors and no
failures, yet I get a system exit.
sys.exit(0) is just a normal way to exit a program, and it is implemented as
'raise SystemExit'. You seem to be running your test from within ipython
which probably catches SystemExit exceptions to prevent you from losing
state. Try running your test from the shell and all should be OK.

Peter
Aug 30 '06 #2

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

Similar topics

6
3676
by: Tom Verbeure | last post by:
Hello All, so I'm now convinced that unit testing is really the way to go and I want to add it to an existing project. The first thing that I find out, is that, well, it's hard work. Harder than writing the real functional code. My application manipulates graphs. I first write the skeleton in Python, then convert it to C++ for high...
4
3056
by: Edvard Majakari | last post by:
Hi, I just found py.test and converted a large unit test module to py.test format (which is actually almost-no-format-at-all, but I won't get there now). Having 348 test cases in the module and huge test classes, I started to think about splitting classes. Basically you have at least three obvious choises, if you are going for consistency...
19
2424
by: newbiecpp | last post by:
I am looking for a C++ unit testing program. I googled and found there are quite a few there, such as CppTest, C++Test, and DejaGnu. Can someone give me a recommendation among these programs? I want to the software is easy to use and has a nice interface. Please excuse me if it is out of the topic. Thanks in advance!
38
3379
by: Christoph Zwerschke | last post by:
In August 2001, there was a thread about the "Art of Unit Testing": http://groups.google.com/group/comp.lang.python/browse_frm/thread/aa2bd17e7f995d05/71a29faf0a0485d5 Paul Moore asked the legitimate question why there is no hook for a "global" fixture code that is run only once for the whole TestCase, as opposed to the normal "setUp" and...
14
2728
by: | last post by:
Hi! I'm looking for unit-testing tools for .NET. Somthing like Java has --> http://www.junit.org regards, gicio
2
3212
by: Naveen Mukkelli | last post by:
Hi, I'm writing a client/server application using C#. The server accepts connecitons asynchronously, using BeginAccept/EndAccept. Is there any way we can write some unit tests(NUnit) to test the behaviour of accepting connections and testing some other private methods that would be called when the server receives a connection request.
72
5197
by: Jacob | last post by:
I have compiled a set og unit testing recommendations based on my own experience on the concept. Feedback and suggestions for improvements are appreciated: http://geosoft.no/development/unittesting.html Thanks.
10
4513
by: Sean Chambers | last post by:
Hello, I am attempting to utilize the MVP pattern in a new app I am building. I am using TDD, along with mock views attached to the View interface to attempt to unit test the UI. The problem I am having is when using the InitView() of the presenter, normally I would be retrieving data from NHibernate when InitView is called. Therein...
176
8286
by: nw | last post by:
Hi, I previously asked for suggestions on teaching testing in C++. Based on some of the replies I received I decided that best way to proceed would be to teach the students how they might write their own unit test framework, and then in a lab session see if I can get them to write their own. To give them an example I've created the...
0
8230
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7810
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8096
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6451
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5618
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5299
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3739
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1337
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1056
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.