#25941: Improve the error message for runtests.py when Django isn't on the path
--------------------------------------+------------------------------------
     Reporter:  Keryn Knight          |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  Testing framework     |                  Version:  master
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------
Description changed by Anton Samarchyan:

Old description:

> Every time I think about contributing, literally the first thing I want
> to do is do a `git clone` and run the tests.
> This is currently annoying, because it requires (according to the
> documentation), my either adding the newly cloned directory to my path
> permanently (and knowing how to do that. I do, but it raises the barrier
> to entry for others) or having cloned it via git which intrinsically puts
> it on the path and smashes it into a `src` directory.
>
> Instead, I have to go and look in the documentation (which is squirrelled
> away via `Documentation -> How to get involved -> Write unit tests`) and
> find `PYTHONPATH=..:$PYTHONPATH ./runtests.py` because there's literally
> no chance I'm going to remember the specifics of that every time I
> sporadically want to get involved (questions in could go through my mind:
> do I need to put a semi-colon in? Do I need to export it? do I need to
> provide a specific settings file?)
>
> Executing `./runtests.py` without the incantation helpfully just errors
> with:
> {{{
> Traceback (most recent call last):
>   File "./runtests.py", line 13, in <module>
>     import django
> ImportError: No module named django
> }}}
> or if you're in a virtualenv with an older extant copy of Django (by way
> of example) ...
> {{{
> Traceback (most recent call last):
>   File "./runtests.py", line 18, in <module>
>     from django.test.runner import default_test_processes
> ImportError: cannot import name 'default_test_processes'
> }}}
> rather than let me know how to get back on the straight and narrow.
>
> The barrier to entry ''is too high''. If `runtests.py` cannot execute, a
> better error message would be useful. Ostensibly something like the
> following would probably work, for the fresh clone scenario (but not the
> already-installed-on-path one):
> {{{
> try:
>     import django
> except ImportError:
>     sys.stdout.write("Some error message explaining how to run the
> thing\n")
>     sys.exit(1)
> }}}
> Really though, a single entry point `./runtests.sh` which passes through
> arguments (`$@` I think?) that might want to be changed would make life
> easier from both a user and documentation standpoint ("just run the shell
> script in the tests directory")
>
> (Additional note: there is a `README.rst` file in the `tests` directory,
> but it a) says to `cd` to a directory which does not exist if you're
> already in the directory [which you probably are to run the tests the
> documented way] and b) requires installing requirements files that the
> quickstart doesn't)

New description:

 Every time I think about contributing, literally the first thing I want to
 do is do a `git clone` and run the tests.
 This is currently annoying, because it requires (according to the
 documentation), my either adding the newly cloned directory to my path
 permanently (and knowing how to do that. I do, but it raises the barrier
 to entry for others) or having cloned it via pip which intrinsically puts
 it on the path and smashes it into a `src` directory.

 Instead, I have to go and look in the documentation (which is squirrelled
 away via `Documentation -> How to get involved -> Write unit tests`) and
 find `PYTHONPATH=..:$PYTHONPATH ./runtests.py` because there's literally
 no chance I'm going to remember the specifics of that every time I
 sporadically want to get involved (questions in could go through my mind:
 do I need to put a semi-colon in? Do I need to export it? do I need to
 provide a specific settings file?)

 Executing `./runtests.py` without the incantation helpfully just errors
 with:
 {{{
 Traceback (most recent call last):
   File "./runtests.py", line 13, in <module>
     import django
 ImportError: No module named django
 }}}
 or if you're in a virtualenv with an older extant copy of Django (by way
 of example) ...
 {{{
 Traceback (most recent call last):
   File "./runtests.py", line 18, in <module>
     from django.test.runner import default_test_processes
 ImportError: cannot import name 'default_test_processes'
 }}}
 rather than let me know how to get back on the straight and narrow.

 The barrier to entry ''is too high''. If `runtests.py` cannot execute, a
 better error message would be useful. Ostensibly something like the
 following would probably work, for the fresh clone scenario (but not the
 already-installed-on-path one):
 {{{
 try:
     import django
 except ImportError:
     sys.stdout.write("Some error message explaining how to run the
 thing\n")
     sys.exit(1)
 }}}
 Really though, a single entry point `./runtests.sh` which passes through
 arguments (`$@` I think?) that might want to be changed would make life
 easier from both a user and documentation standpoint ("just run the shell
 script in the tests directory")

 (Additional note: there is a `README.rst` file in the `tests` directory,
 but it a) says to `cd` to a directory which does not exist if you're
 already in the directory [which you probably are to run the tests the
 documented way] and b) requires installing requirements files that the
 quickstart doesn't)

--

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

Reply via email to