[TIP] how can I find in TestCase whether runs verbosely?

Chris Jerdonek chris.jerdonek at gmail.com
Sun Feb 17 16:09:07 PST 2013

On Sun, Feb 17, 2013 at 3:29 PM, Robert Collins
<robertc at robertcollins.net> wrote:
> On 18 February 2013 08:47, Matěj Cepl <mcepl at redhat.com> wrote:
>> Hi,
>> I would like to make my unittest testsuite to drop some intermediate
>> test results when it is run with -v in the verbose mode. How can I find
>> out in the TestCase object, that the run is verbose?
> Can I ask why?
> Background:
> The idea is that there are two completely separate(*) things happening :
> Tests are running
> Something is showing the result of those tests to users.
> Then, the tests should give all data to the result all the time, and
> the result can choose whether to show a particular thing or not (and
> how to do so - write to XML, print to screen, submit to a web
> server...)

I agree with Robert's point, but for the record there are at least a
couple parts of the existing TestCase API that control how much data
is given, for example the longMessage and maxDiff attributes of


So it is possible that there are valid use cases.


> So having tests be aware of verbosity is a layering issue that would
> make test code more complex and reduce the freedom of results to do
> $whatever they want - unless they advertise verbose mode always and
> then report less verbose later :)
> For a concrete example of this sort of separation, look at
> disttrial/py.test in distributed mode or testrepository, all of which
> have quite separate actual reporting from where the tests are
> happening.
> I have a new result protocol that allows a lot more and fixes a number
> of issues that turn up in practice in draft -
> https://github.com/rbtcollins/testtools/tree/streamresult - so if we
> need to add verbosity feedback to it, this would be the right time to
> do so, before I get to the PEP stage).
> So I'm guessing you have something you want to do, but I'm not sure
> why the test case needs to know.
> -Rob
> --
> Robert Collins <rbtcollins at hp.com>
> Distinguished Technologist
> HP Cloud Services
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python

More information about the testing-in-python mailing list