~jmillikin/+junk/python-multipart

« back to all changes in this revision

Viewing changes to test_multipart.py

  • Committer: John Millikin
  • Date: 2008-09-25 02:55:52 UTC
  • Revision ID: jmillikin@gmail.com-20080925025552-dbt6avgo9guy22pa
Added a test that encoding binary files isn't stuffed up by unicode handling.

Show diffs side-by-side

added added

removed removed

Lines of Context:
132
132
                        '--BOUNDARY--\r\n',
133
133
                )
134
134
                
 
135
        def test_encode_file_binary (self):
 
136
                fileobj = StringIO.StringIO ("<->\xff\xfe\xfd<->")
 
137
                fileobj.name = "filename"
 
138
                self.check_encode ({'a': fileobj},
 
139
                        '--BOUNDARY\r\n'
 
140
                        'Content-Disposition: form-data; name="a"; filename="filename"\r\n'
 
141
                        'Content-Type: "application/octet-stream"\r\n'
 
142
                        '\r\n'
 
143
                        '<->\xff\xfe\xfd<->\r\n'
 
144
                        '--BOUNDARY--\r\n',
 
145
                )
 
146
                
135
147
        def check_raises (self, params, boundary, error_message):
136
148
                try:
137
149
                        content, headers = multipart.encode (params, boundary)