#23778: Running tests outside the test runner needs clarification
--------------------------------------+-----------------------------
     Reporter:  Starou                |      Owner:  nobody
         Type:  Cleanup/optimization  |     Status:  new
    Component:  Documentation         |    Version:  1.7
     Severity:  Normal                |   Keywords:  tests run_tests
 Triage Stage:  Unreviewed            |  Has patch:  0
Easy pickings:  0                     |      UI/UX:  0
--------------------------------------+-----------------------------
 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'])

 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23778>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.4d8ff1708bacccadae674176070b7a57%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to