[TIP] How do I get coverage on the test modules themselves?
John Yeuk Hon Wong
gokoproject at gmail.com
Mon Sep 15 19:43:08 PDT 2014
On 9/15/14 10:16 PM, Ben Finney wrote:
> "Mcgregor, Cecil" <cmcgregor at paypal.com> writes:
>> How do I cover the test_*.py files as part of the coverage reports?
> You'll need to design tests which test *that* code, and run them. This
> is, as you might gather, a recursive loop which can go on indefinitely.
I will add that there is test harness and assertions. If you write a test
harness, you can write tests to test that harness.
If self.assertEqual(...) is wrong but tested positive, that is not an error
you can test. Code that leads to the assertions (calling HTTP to get
the content of a webpage and assert it has the title "Hello World")
can be refactored out as part of your test harness. You can called it
get_webpage(url) as an independent function outside of your
test class. That you can choose to test it. You don't have to.
Some assurance on your test harness is indeed a good practice,
but I think that's about it. Over-testing can lead to problems.
More information about the testing-in-python