#23778: Running tests outside the test runner needs clarification
--------------------------------------+------------------------------------
     Reporter:  Starou                |                    Owner:  Starou
         Type:  Cleanup/optimization  |                   Status:  assigned
    Component:  Documentation         |                  Version:  1.7
     Severity:  Normal                |               Resolution:
     Keywords:  tests run_tests       |             Triage Stage:  Accepted
    Has patch:  1                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------

Comment (by Starou):

 Replying to [comment:4 prestontimmons]:
 > This example is okay. I have a couple thoughts, though:
 >
 > I assume the most common case for this is creating a test runner for
 reusable apps. In that case, messing with `PYTHONPATH` is often
 unnecessary since you can either `pip install --editable` or `python
 setup.py develop` to put your packages on the path. Is it worth mentioning
 this?

 Hi Preston,

 The PYTHONPATH in the PR snippet is about resolving
 `DJANGO_SETTINGS_MODULE` by adding the path of the test project, not the
 reusable app dev sources path (which is assumed). But maybe this is not
 clear enough ?

 >
 > The example hard-codes the app label in `runner.run_tests(['my_app'])`.
 Even with reusable apps it's nice to have the option of passing a path to
 a test case, like `./runtests.py myapp.tests.SomeCase.test`. Should the
 example take that into consideration?
 >
 > I usually do something like:
 >
 > {{{
 > runner.runtests(sys.argv[1:] or ["myapp"])
 > }}}

 Good point.
 I wanted the snippet as simple as possible (how to convert a `manage.py
 test` shell invocation into Python code). In that regard, I would replace
 `sys.argv[1:] or ['myapp']` by `sys.argv[1:]` and update the runtests.py
 invocation example with some optional arguments ''à la Django''
 
(`[path.to.modulename|path.to.modulename.TestCase|path.to.modulename.TestCase.test_method]`).
 What do you think ?

--
Ticket URL: <https://code.djangoproject.com/ticket/23778#comment:5>
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/064.f76393a4571841054dbe654a18556868%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to