media directory for testing

11 views
Skip to first unread message

Faheem Mitha

unread,
Nov 10, 2007, 4:52:27 PM11/10/07
to django...@googlegroups.com

Hi.

I'm having the following problem while testing. I'm writing a unit test
for a file upload (using newforms). This works. However, the file gets
written to the same media directory as is used in normal work. I'd prefer
this happened somewhere where it would have no impact on normal
functioning, possibly /tmp. Does anyone have suggestions on what to do?
One workaround would be to redefine the media directory in the tests
themselves, if I can figure out how to do that...
Faheem.

Malcolm Tredinnick

unread,
Nov 10, 2007, 7:43:41 PM11/10/07
to django...@googlegroups.com

The "normal" would be to have a settings file that is used specifically
for testing. You can put "from normal_settings import *" at the top and
then just override the settings you need to.

It's not always going to be the case that you development, production
and testing settings are identical. So take advantage of the fact you
can have multiple settings files.

Regards,
Malcolm

--
For every action there is an equal and opposite criticism.
http://www.pointy-stick.com/blog/

Amit Ramon

unread,
Nov 12, 2007, 1:03:27 AM11/12/07
to django...@googlegroups.com
Another solution is to use environment variables for the settings that are
different. You can then use the same settings file for all different
environments. All you have to do is to read the environment variables in the
settings file, something like:

DATABASE_NAME = os.environ["DATABASE_NAME"]

Cheers,

Amit

ביום ראשון 11 נובמבר 2007, 02:43, נכתב על ידי Malcolm Tredinnick:

Reply all
Reply to author
Forward
0 new messages