[Django] #25941: Supply a runtests.sh in the tests directory.

10 views
Skip to first unread message

Django

unread,
Dec 15, 2015, 9:43:47 AM12/15/15
to django-...@googlegroups.com
#25941: Supply a runtests.sh in the tests directory.
-----------------------------------+--------------------
Reporter: kezabelle | Owner: nobody
Type: New feature | Status: new
Component: Testing framework | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------
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)

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

Django

unread,
Dec 15, 2015, 9:58:09 AM12/15/15
to django-...@googlegroups.com
#25941: Supply a runtests.sh in the tests directory.
-----------------------------------+--------------------------------------

Reporter: kezabelle | Owner: nobody
Type: New feature | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by kezabelle):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

A word of clarification, in the original ticket I said ''having cloned it


via git which intrinsically puts it on the path and smashes it into a src

directory'' where I actually meant `pip`, rather than `git`.

--
Ticket URL: <https://code.djangoproject.com/ticket/25941#comment:1>

Django

unread,
Dec 15, 2015, 10:09:03 AM12/15/15
to django-...@googlegroups.com
#25941: Supply a runtests.sh in the tests directory.
-----------------------------------+--------------------------------------

Reporter: kezabelle | Owner: nobody
Type: New feature | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by MoritzS):

Wouldn't the recommended workflow be more like the following?

{{{
. ./my/test/venv/bin/activate
git clone url/to/django.git
cd django
pip install -e .
cd tests
pip install -r requirments/py3.txt
./runtests.py
}}}

If you do it like that you won't have to fiddle with `PYTHONPATH` and you
also won't run into trouble with having installed multiple possibly older
versions of Django.

--
Ticket URL: <https://code.djangoproject.com/ticket/25941#comment:2>

Django

unread,
Dec 15, 2015, 10:13:43 AM12/15/15
to django-...@googlegroups.com
#25941: Improve the error message for runtests.py when Django isn't on the path
--------------------------------------+------------------------------------
Reporter: kezabelle | 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
--------------------------------------+------------------------------------
Changes (by timgraham):

* type: New feature => Cleanup/optimization
* stage: Unreviewed => Accepted


Comment:

I'm not so enthusiastic about providing a shell script, however, I
wouldn't object to a better error message for `runtests.py` for the
"import django" ImportError. It could point at `tests/README.rst` and that
file could be updated with the workflow suggested by Moritz.

--
Ticket URL: <https://code.djangoproject.com/ticket/25941#comment:3>

Django

unread,
Dec 15, 2015, 10:37:01 AM12/15/15
to django-...@googlegroups.com
#25941: Improve the error message for runtests.py when Django isn't on the path
--------------------------------------+------------------------------------
Reporter: kezabelle | 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
--------------------------------------+------------------------------------

Comment (by kezabelle):

The suggested workflow is not the same though, is it? The PYTHONPATH
twiddling, though a pain to remember, isn't '''installing''' django into
your environment, it's just adjusting it temporarily (for the test run).
This is a marked difference (because actually, the invocation ''can just''
be `PYTHONPATH=.. ./runtests.py --parallel=N` for the simple case within
the tests dir, AFAIK). I'm also unconvinced why I need to ''install'' it
at all - the available documentation (online and in the `README.rst`)
already demonstrates it is unnecessary to do so. And I rather presume that
the quickstart wasn't arrived at by choosing the least memorable way of
executing the tests.

--
Ticket URL: <https://code.djangoproject.com/ticket/25941#comment:4>

Django

unread,
Dec 15, 2015, 10:53:59 AM12/15/15
to django-...@googlegroups.com
#25941: Improve the error message for runtests.py when Django isn't on the path
--------------------------------------+------------------------------------
Reporter: kezabelle | 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
--------------------------------------+------------------------------------

Comment (by MoritzS):

Replying to [comment:4 kezabelle]:


> because actually, the invocation ''can just'' be `PYTHONPATH=..
./runtests.py --parallel=N` for the simple case within the tests dir,
AFAIK

That's not exactly true. You can't run a large number of tests if you
didn't `pip install -r tests/requirements/py3.txt` before. That means you
always have to "initialize" your environment (beyond cloning the git repo)
to be able to run most of the tests.

--
Ticket URL: <https://code.djangoproject.com/ticket/25941#comment:5>

Django

unread,
Dec 15, 2015, 11:04:54 AM12/15/15
to django-...@googlegroups.com
#25941: Improve the error message for runtests.py when Django isn't on the path
--------------------------------------+------------------------------------
Reporter: kezabelle | 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
--------------------------------------+------------------------------------

Comment (by kezabelle):

Of that I'm aware; I was demonstrating that even referencing any prior
$PYTHONPATH is not actually a requirement (again, AFAIK, and again, I'm
sure there are reasons the quick-start includes it); and I think the
runtests script actually prevents any tests from running without
requirements having been installed (and tells you what to do!)

--
Ticket URL: <https://code.djangoproject.com/ticket/25941#comment:6>

Django

unread,
Jan 10, 2017, 1:56:06 PM1/10/17
to django-...@googlegroups.com
#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:

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

--

--
Ticket URL: <https://code.djangoproject.com/ticket/25941#comment:7>

Django

unread,
Apr 13, 2019, 6:14:25 AM4/13/19
to django-...@googlegroups.com
#25941: Improve the error message for runtests.py when Django isn't on the path
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Thomas
Type: | Allison
Cleanup/optimization | Status: assigned

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
-------------------------------------+-------------------------------------
Changes (by Thomas Allison):

* status: new => assigned
* owner: nobody => Thomas Allison


--
Ticket URL: <https://code.djangoproject.com/ticket/25941#comment:8>

Django

unread,
Apr 13, 2019, 8:01:33 AM4/13/19
to django-...@googlegroups.com
#25941: Improve the error message for runtests.py when Django isn't on the path
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Thomas
Type: | Allison
Cleanup/optimization | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Thomas Allison):

* has_patch: 0 => 1


Comment:

PR for patch: https://github.com/django/django/pull/11210

--
Ticket URL: <https://code.djangoproject.com/ticket/25941#comment:9>

Django

unread,
Apr 13, 2019, 10:10:39 AM4/13/19
to django-...@googlegroups.com
#25941: Improve the error message for runtests.py when Django isn't on the path
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Thomas
Type: | Allison
Cleanup/optimization | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/25941#comment:10>

Django

unread,
Apr 13, 2019, 12:35:01 PM4/13/19
to django-...@googlegroups.com
#25941: Improve the error message for runtests.py when Django isn't on the path
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Thomas
Type: | Allison
Cleanup/optimization | Status: closed

Component: Testing framework | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"3e8b7333904f1ab6aa18eeb508659256f3644816" 3e8b7333]:
{{{
#!CommitTicketReference repository=""
revision="3e8b7333904f1ab6aa18eeb508659256f3644816"
Fixed #25941 -- Improved error message for runtests.py when django is not
on path.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25941#comment:11>

Reply all
Reply to author
Forward
0 new messages