On 6/26/07, Michal <[EMAIL PROTECTED]> wrote:
>
> Hello,
> I try to write test together with coverage [1]. This tool could tell me,
> which lines of code was or wasn't executed and therefore tell, how my
> tests are (or aren't) "superior".
>
> I put initial code for coverage into setUp, and cleanup to tearDown
> method of Testcase class. Problem is, that setUp and tearDown method are
> called before/after each particular test in TestCase.
>
> I need to find technique, which enable me initiate coverage before any
> test begin, and cleanup after *all* test was executed. Do you have some
> advice please?

Hi Michal

The approach here will be to write your own test runner method. When
you call 'manage.py test', Django is effectively calling a method
called django.test.simple.run_tests(); this method sets up the test
environment, finds the tests, runs the tests, and cleans up the test
environment.

However, you can direct django to point at a different method of your
own choosing. Define a method like:

from django.tests.simple import run_tests

def coverage_run_tests(module_list, verbosity=1, extra_tests=[]):
   setup_coverage()
   retval = run_tests(module_list, verbosity, extra_tests)
   cleanup_coverage()
   return retval

then, in your settings file, define
TEST_RUNNER='myapp.coverage_run_tests', and Django will  use your
instrumented run_tests implementation.

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to