4

i try to override DJango 1.6 custom testrunner, i want to override the teardown_database and teardown_test methods to avoid deletion of test data (i want to look inside the db...):

#!/usr/bin/env python

from django.test.simple import DjangoTestSuiteRunner
from django.conf import settings

class KeepDBTestRunner(DjangoTestSuiteRunner):

    def teardown_databases(self, old_config, **kwargs):
        pass

    def teardown_test_environment(self, **kwargs):
        pass

But when i run the manage.py test with testrunner with --testrunner option i get:

Creating test database for alias 'default'
...
Ran 230 tests in 1.364s

Without custom testrunner it run only the 3 test that i have wrote.

What's wrong with my custom testrunner, i override a simple method but seems that system run another test set....

Thanks.

2
  • Do you specify the app name while executing test command? Commented Jul 23, 2014 at 13:40
  • If i specify the app name it execute the correct test set (3 tests..), the database is created correctly, but without data... Commented Jul 23, 2014 at 13:53

1 Answer 1

2

Another way you can do this is by pointing Django at your custom test runner class by setting the TEST_RUNNER variable in settings.py

e.g.

TEST_RUNNER = 'mymodule.KeepDBTestRunner'

see https://docs.djangoproject.com/en/1.11/ref/settings/#std:setting-TEST_RUNNER

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.