Hi,

I think it might be useful to define a variable (such as TESTS) in
settings, which will only be True when running tests, and then Django will
know we are running tests and act accordingly, for example save files in a
different directory (such as TESTS_MEDIA_ROOT) and not in the default
MEDIA_ROOT directory, and delete them after all the tests end. And other
actions which should run only in tests or only not in tests.

If such a variable is defined, its default value should be of course False.

https://code.djangoproject.com/ticket/30605

Please see my recent comment on this ticket:
https://code.djangoproject.com/ticket/23251

I already defined different settings files in Speedy Net, and set
set django_settings.TESTS to True only in tests. Until recently it was
possible to run tests with other settings such as development, when running
tests locally, but now it's deliberately disabled (with two asserts
in speedy/core/base/test/models.py) because I don't want tests to run with
the production (or development) MEDIA_ROOT settings.

Also notice, I used django_settings.TESTS_MEDIA_ROOT instead
of django_settings.MEDIA_ROOT in tearDownClass in the above file, to
prevent deleting the production MEDIA_ROOT directory by accident if the
tests will still run in production (although it can't because of the
asserts above).

I will appreciate your feedback or comments.

אורי
u...@speedy.net

-- 
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-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CABD5YeFxQWQqiYxGSRm3jSUUzYvpO52Cc9B0MXtq0XfVyF6AHw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to