Ahh ok then, it looks like I am using paste.fixture

Anyway, I found out what the problem was, it was with the filename.

filename = u"test.jpg"
upload_files=('test', filename)

fails but

filename = "test.jpg"
upload_files=('test', filename)

works. And

filename = u"test.jpg"
upload_files=('test', filename.encode('utf-8'))

also works.

Very similar to what tripped me up last time.

On Thu, Dec 18, 2008 at 8:46 AM, Jorge Vargas <[email protected]> wrote:
>
> On Wed, Dec 17, 2008 at 6:22 AM, Kurt Häusler <[email protected]> wrote:
>>
>> I am using nosetests. If I only pass one file in it does not work. The
>> only combination that works is params only without the upload_files.
>>
> nose it's a test runner & finder not a testing engine in itself, the
> feature you want to use is either part of webtest or paste.fixture
>
>> I also tried wrapping the file contents in a StringIO but only a
>> string or unicode is accepted. I also tried writing a real file to
>> disk first and only providing the tag and filename but that didn't
>> help either.
>>
>> On Wed, Dec 17, 2008 at 12:52 PM, Jorge Vargas <[email protected]> 
>> wrote:
>>>
>>> On Wed, Dec 17, 2008 at 3:54 AM, Kurt <[email protected]> wrote:
>>>>
>>>> Hi, I have a controller, that takes a normal param, as well as a
>>>> couple of files as input. It works fine when called from a client, but
>>>> I am having trouble getting a unit test to work.
>>>>
>>>> response = self.app.post(url_for(controller='ff', action='upload'),
>>>> params={'packxml': packxml}), \
>>>>            upload_files = [(tempimageid + '.image',
>>>> tempimagefilename, 'IMAGECONTENTS'), \
>>>>            (tempimageid + '.icon', tempiconfilename,
>>>> 'ICONCONTENTS')])
>>>>
>>>> If i only pass in the params, but no upload_files then the packxml
>>>> param is correctly passed to the controller in request.params.
>>>> However when  I try either the upload_files by itself, or both the
>>>> params and upload_files, then request.params is empty.
>>>>
>>>> My controller would like to access the files as request.params
>>>> ['id'].value
>>>>
>>>> Whats going on here? Are file params passed into the controller in
>>>> some other structure than request.params? If files are passed in, are
>>>> normal params also passed in differently? Can both types of params be
>>>> passed in in the same request using self.app.post?
>>>>
>>>> Any tips would be appreciated.
>>>
>>> are you using webtest?I got equivalent code and it works fine. does it
>>> works with only one file?
>>>
>>> >
>>>
>>
>> >
>>
>
> >
>

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

Reply via email to