473,394 Members | 1,735 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,394 software developers and data experts.

problem including tests in unittest

I have a module for which I am trying to code a unit test. However,
when I run unittest.main(), I get:

In [1]: import PyMC

In [2]: PyMC.unittest.main()

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK
This is confusing, because I have set up a class called MCMCTest that
is a sublcass of unttest.TestCase, which in turn contains a test
method. Yet, unittest seems not to be aware of it. Is there anything I
am forgetting?

Thanks,
Chris

--
Chris Fonnesbeck + Atlanta, GA + http://trichech.us
Oct 12 '06 #1
1 3923
Chris Fonnesbeck wrote:
I have a module for which I am trying to code a unit test. However,
when I run unittest.main(), I get:

In [1]: import PyMC

In [2]: PyMC.unittest.main()

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK
This is confusing, because I have set up a class called MCMCTest that
is a sublcass of unttest.TestCase, which in turn contains a test
method. Yet, unittest seems not to be aware of it. Is there anything I
am forgetting?
By default unittest.main() scans the __main__ module for TestCases.
Though you could use it from an interactive interpreter
>>import unittest
unittest.main("PyMC", argv=["yadda", "-v"])
test_alpha (PyMC.Test) ... ok
test_beta (PyMC.Test) ... ok

----------------------------------------------------------------------
Ran 2 tests in 0.000s

OK
$ # Oops

without countermeasures unittest.main() will exit that too after completion.
The normal usage (the only one I know) is to put it inside the test script:

# your testcases
if __name__ == "__main__":
unittest.main()

and run that from the shell:

$ python PyMC.py -v
test_alpha (__main__.Test) ... ok
test_beta (__main__.Test) ... ok

----------------------------------------------------------------------
Ran 2 tests in 0.001s

OK

Peter
Oct 12 '06 #2

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

Similar topics

12
by: Paul Moore | last post by:
One of the things I really dislike about Unittest (compared, say, to a number of adhoc testing tricks I've used in the past, and to Perl's "standard" testing framework) is that the...
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...
1
by: travislspencer | last post by:
Hey All, I am trying to write a script that runs all of my pyunit tests for me. Ideally, I would like to be able to drop a new module into my project's test subdirectory, and the testing script...
2
by: Ben Finney | last post by:
Howdy all, My practice when writing unit tests for a project is to make 'test/' subdirectories for each directory containing modules I want to test. project-foo/ +-- lib/ | +-- test/ +--...
6
by: Ben Finney | last post by:
Howdy all, Summary: I'm looking for idioms in unit tests for factoring out repetitive iteration over test data. I explain my current practice, and why it's unsatisfactory. When following...
5
by: alainpoint | last post by:
Hi, I have what in my eyes seems a challenging problem. Thanks to Peter Otten, i got the following code to work. It is a sort of named tuple. from operator import itemgetter def...
1
by: Pupeno | last post by:
Hello, Having A(unittest.TestCase) and B(A), the unittests framework seems not to run A's test when testing B, right ? If so, is there any way to 'fix' it ? that is, make all tests in A, also run...
1
by: jimburton | last post by:
I have a number of unit tests organised hierarchically, all of which inherit fixtures from a base class. To run these all at once I started out using from basic import map, directionalpan,...
0
by: Roy Smith | last post by:
I'm starting a new project and am thinking of embedding my unit tests right in the source files. I've used unittest before, and I'm happy with it, but I've always used it with the source code in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...
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...

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.