﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
23778	Running tests outside the test runner needs clarification	Stanislas Guerra	Stanislas Guerra	"Hi devs,

=== ''Some context first''

For one of my pluggable application I have two different test suites, one of them being a Django dummy project.
In order to have a correct Coverage report, I run both of them in a runtests.py script.

[https://docs.djangoproject.com/en/dev/topics/testing/advanced/#running-tests-outside-the-test-runner The Documentation] is a bit confusing and I think a working snippet could be useful here.

For example, it is not required to execute `setup_test_environment()` nor `django.test.runner.DiscoverRunner.setup_databases()` if you execute `DiscoverRunner.run_tests()` which is what you want in the end.

The following snippet could be useful to the newcomers don't you think ?

{{{
import os
import sys
import django
from django.test.runner import DiscoverRunner

sys.path.insert(0, '../..')  # path to the development sources.
sys.path.insert(0, 'test_project')  # path the the test project.
os.environ['DJANGO_SETTINGS_MODULE'] = 'test_project.settings'
os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS'] = '127.0.0.1:8082'

django.setup()
runner = DiscoverRunner()
runner.run_tests(['my_app'])

}}}

"	Cleanup/optimization	closed	Documentation	1.7	Normal	fixed	tests run_tests		Accepted	1	0	0	1	0	0
