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.m ain()
----------------------------------------------------------------------
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.TestCas e, 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 1 3932
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.m ain()
----------------------------------------------------------------------
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.TestCas e, 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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 testcase-as-a-class model
tends to imply a relatively high granularity in testing.
A good example of this comes from "Dive Into Python"...
|
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 old lines at the end:
if __name__ == "__main__":
unittest.main()
This is great, because each of the modules are runnable, and I can select...
|
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 will pick it up
automatically.
At the moment, I have it working but it is kinda a kludge because
every TestCase must provide a function that...
|
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/
+-- data/
+-- gui/
|
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 test-driven development, writing tests and then coding
to satisfy them, I'll start with some of the simple tests for a class.
| |
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 constgetter(value):
def get(self): return value
return get
def createTuple(*names):
|
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
for B ?
Thanks.
--
Pupeno <pupeno@pupeno.com(http://pupeno.com)
|
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, layerorder, layervisibility,
listlayers, streamlayerlist
# ... lots more ...
suite0 =...
|
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 one file and
the unit tests in another. I figure if I just put a
if __name__ == '__main__":
import unittest
blah, blah, blah
block at the end...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |