Adding hard dependencies to Django's test suite

131 views
Skip to first unread message

Tim Graham

unread,
Nov 27, 2014, 8:42:46 PM11/27/14
to django-d...@googlegroups.com
There have been some proposals to add new dependencies in Django's test suite:

1. #23289 - unittest.mock (included in Python 3.3+; a backport version would need be installed when testing on Python 2.7 and 3.2)
2. #23792 - freezegun (to freeze time.time() and fix some non-deterministic tests, rather than create our own "poor freezegun" utility in django.test)

Our current policy is that all test dependencies are optional and if they aren't installed, the test is skipped. I'd like to think that Python packaging is mature enough that we could consider adding some "hard dependencies" like the above (and perhaps removing the existing skip requirement entirely) such that runtests.py would thrown an error if it doesn't find any required dependencies rather than continue down the path of skipping tests which can be tedious. We have the test dependencies in requirements files (see tests/requirements) so installing the dependencies is fairly painless using pip.

While I know the idea that you can simply clone Django and run the tests straight away is appealing, I believe the fact that Python 3.4 includes pip and virtualenv should allow us to move forward here. If this nudges people to contribute to Django using Python 3 in their local environment, I'd consider that a win. If the Django Girls tutorial can use Python 3 (albeit with the help of a coach), I'd think Django's contributing docs could take this approach as well.

What do you think?

Fabio Caritas Barrionuevo da Luz

unread,
Nov 27, 2014, 11:03:01 PM11/27/14
to django-d...@googlegroups.com
python 2.7.9 rc1 include a backported version of python3 ensurepip

see: 

https://hg.python.org/cpython/rev/592a5414fabd
https://docs.python.org/2/library/ensurepip.html

Marc Tamlyn

unread,
Nov 28, 2014, 3:30:18 AM11/28/14
to django-d...@googlegroups.com
I agree. Anyone wanting to contribute to Django should be able to run a pip install -r test_requirements.txt.

Marc

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/173434d5-3313-47b6-bfed-07463c58aa8a%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Carl Meyer

unread,
Nov 28, 2014, 11:56:04 AM11/28/14
to django-d...@googlegroups.com
On 11/27/2014 06:42 PM, Tim Graham wrote:
> There have been some proposals to add new dependencies in Django's test
> suite:
>
> 1. #23289 <https://code.djangoproject.com/ticket/23289> - unittest.mock
> (included in Python 3.3+; a backport version would need be installed
> when testing on Python 2.7 and 3.2)
> 2. #23792 <https://code.djangoproject.com/ticket/23792> - freezegun (to
> freeze time.time() and fix some non-deterministic tests, rather than
> create our own "poor freezegun" utility in django.test)
>
> Our current policy is that all test dependencies are optional and if
> they aren't installed, the test is skipped. I'd like to think that
> Python packaging is mature enough that we could consider adding some
> "hard dependencies" like the above (and perhaps removing the existing
> skip requirement entirely) such that runtests.py would thrown an error
> if it doesn't find any required dependencies rather than continue down
> the path of skipping tests which can be tedious. We have the test
> dependencies in requirements files (see tests/requirements) so
> installing the dependencies is fairly painless using pip.
>
> While I know the idea that you can simply clone Django and run the tests
> straight away is appealing, I believe the fact that Python 3.4 includes
> pip and virtualenv should allow us to move forward here. If this nudges
> people to contribute to Django using Python 3 in their local
> environment, I'd consider that a win. If the Django Girls tutorial can
> use Python 3 (albeit with the help of a coach), I'd think Django's
> contributing docs could take this approach as well.
>
> What do you think?

I think we should feel free to add required dependencies for running the
tests.

As Fabio points out, even Python 2.7 will soon have pip built-in.

Carl

signature.asc

Jannis Leidel

unread,
Nov 28, 2014, 12:36:27 PM11/28/14
to django-d...@googlegroups.com
+1 on assuming pip or another installer for running the Django tests.

Providing a requirements file for the tests is even more awesome, but let's say no to VCS requirements and always require the dependencies to be hosted on PyPI.

Jannis

Collin Anderson

unread,
Nov 29, 2014, 5:31:59 PM11/29/14
to django-d...@googlegroups.com
I'm -0 for freezegun, +0 for unittest.

I see unittest as a polyfill that we'll only need to keep around for about 3 years, and I like the "nudging people to use python3"

Freezegun is a less popular, less established library, and I'd personally still rather see it be an optional dependency. 

I think pip helps a lot with dependencies, but I don't think it solves all problems. It would still be great to run and test django without needing to use a virtual environment (even if only on the latest version of python).

(But, as always, I'm not the one writing the tests :)

Collin
Reply all
Reply to author
Forward
0 new messages