473,396 Members | 2,016 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,396 software developers and data experts.

Can a test case tell if VERBOSE is used in pyunit test?

Is there a way for a test case method in a class derived
from unittest.TestCase to tell if the harness was started
with the verbose option? I would like my test cases to
print out a little extra information if the tests were run with
-v or -vv.

yours,
Noah

Jan 31 '06 #1
1 1697
Noah wrote:
Is there a way for a test case method in a class derived
from unittest.TestCase to tell if the harness was started
with the verbose option? I would like my test cases to
print out a little extra information if the tests were run with
-v or -vv.


Looking at the source, it doesn't appear that information is exposed to
the TestCases. If you base your tests on this subclass of the standard
TestCase, however, you can use the regenerated "self._verbosity"
attribute to do what you want:
class TestCase(unittest.TestCase):
def run(self, result=None):
if result.showAll:
self._verbosity = 2
elif result.dots:
self._verbosity = 1
else:
self._verbosity = 0
unittest.TestCase.run(self, result=result)
-Peter

Jan 31 '06 #2

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

Similar topics

1
by: Timothy Grant | last post by:
At work we use Perl and a home rolled unittesting mechanism. One of the things I love about That testing mechanism is that I can run one single test. In fact, I've configured Vim to run the current...
10
by: Berthold Hoellmann | last post by:
Hello, When I use ./configure --with-thread --with-fpectl --with-signal-module \ --with-pymalloc --enable-shared --with-cxx=g++ make test on 2.3.3 I get
2
by: Will McGugan | last post by:
What is the best way to do a simple case insensitive comparison in Python? As far as I can tell, the only option is to do str1.lowercase() == str2.lowercase() (or uppercase). But that strikes me...
8
by: StepH | last post by:
Hi, I've this module : from optparse import OptionParser import re _version = "P1" def writeVar(f, line):
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...
2
by: chris | last post by:
We have a number of TestCase classes that have multiple test methods. We are interested in removing any of the individual test methods on the fly (dynamically, at runtime, whatever). We...
5
by: Sakcee | last post by:
Hi I am trying to use pyUnit to create a framework for testing functions I am reading function name, expected output, from a text file. and in python generating dynamic test functions...
0
by: winston.yang | last post by:
Is it possible to use PyUnit to test with multiple threads? I want to send many commands to a database at the same time. The order of execution of the commands is indeterminate, and therefore, so...
176
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...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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:
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
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.