By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,766 Members | 1,401 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,766 IT Pros & Developers. It's quick & easy.

unittest ValueError

P: n/a
I have built the following unit test, observing the examples laid out
in the python docs:

class testMCMC(unittest.TestCase):

def setUp(self):

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

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

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

# 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.sample(iterations, burn=burn,
thin=thin, plot=True))

# Run convergence diagnostics

# Plot autocorrelation

# Goodness of fit
self.failIf(self.sampler.goodness(iterations/10)['overall'] < 0.05)
def test():
# Run unit tests

However, when I run test() from the python shell, it dies:

In [2]: test()

Ran 0 tests in 0.000s

exceptions.SystemExit Traceback (most
recent call last)

/Users/chris/<ipython console>

in test()
2987 def test():
2988 # Run unit tests
-2989 unittest.main()
global unittest.main = <class 'unittest.TestProgram'>

in __init__(self=<unittest.TestProgram object at 0x10e6c10>,
module='__main__', defaultTest=None, argv=['/usr/local/bin/ipython'],
testRunner=None, testLoader=<unittest.TestLoader object at 0x5feb30>)
757 self.progName = os.path.basename(argv[0])
758 self.parseArgs(argv)
--759 self.runTests()
self.runTests = <bound method TestProgram.runTests of
<unittest.TestProgram object at 0x10e6c10>>
761 def usageExit(self, msg=None):

in runTests(self=<unittest.TestProgram object at 0x10e6c10>)
795 self.testRunner = TextTestRunner(verbosity=self.verbosity)
796 result =
--797 sys.exit(not result.wasSuccessful())
global sys.exit = <built-in function exit>
result.wasSuccessful = <bound method
_TextTestResult.wasSuccessful of <unittest._TextTestResult run=0
errors=0 failures=0>>
799 main = TestProgram

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

In [3]: from PyMC import testMCMC

In [4]: foo = testMCMC()
exceptions.ValueError Traceback (most
recent call last)

/Users/chris/<ipython console>

in __init__(self=<PyMC.MCMC.testMCMC testMethod=runTest>,
206 self.__testMethodDoc = testMethod.__doc__
207 except AttributeError:
--208 raise ValueError, "no such test method in %s: %s" % \
global ValueError = undefined
self.__class__ = <class 'PyMC.MCMC.testMCMC'>
methodName = 'runTest'
209 (self.__class__, methodName)

ValueError: no such test method in <class 'PyMC.MCMC.testMCMC'>: runTest
I have no idea why this is happening. My TestCase class begins with
"test", the method begins with "test", yet no tests are seen. Also, I
do not get the runTest ValueError. I assumed that you get this method
for free win TestCase. The examples certainly do not have this method,
so I am not sure what the problem is.

Thanks for any help,
Chris Fonnesbeck + Atlanta, GA +
Jul 24 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.