I have a bunch of unit tests that do file upload too.  E.g.:

    def testBasics(self):
        testpage = self.test_report.page_set.create(slug="testpage", title =
"Test Page")
        self.assertEquals(testpage.report, self.test_report)
        testpage.page_spec.save("testgraphspec.json",
ContentFile(TESTSPECSTR))
        graphspecs = testpage.graphspecs()
        assert "age1" in graphspecs.keys()
        self.assertEquals(graphspecs["age1"].slug, "age1")

I have no idea if this is the best way or not, but it seems that the django
unit test magic does the right thing here, and the file that is created upon
upload gets cleaned up afterward,  without any need to change the MEDIA
location or do other painful things.

Are you using django's "manage.py test" to run the tests?

Lisa


On Wed, Sep 17, 2008 at 11:42 AM, Faheem Mitha <[EMAIL PROTECTED]> wrote:

>
>
> Hi,
>
> I wrote some unit tests for file upload. since I didn't want the files in
> the unit tests to be uploaded to the "official locaion", I changed the
> upload location by reassiging MEDIA_ROOT to something else, '/tmp' in this
> case.
>
> With an upgrade to Django 1.0, this method no longer works. The file
> upload appears to ignore the value of MEDIA_ROOT.
>
> Can anyone suggest another method? Apparently file upload is now more
> flexible - vide http://code.djangoproject.com/wiki/FileStorageRefactor.
> I'm not sure if it is possible to use this kind of functionality to do
> this. Suggestions welcome.
>
>                                                         Thanks, Faheem.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to