diff options
author | Senthil Kumaran <senthil@uthcode.com> | 2013-01-23 11:00:26 (GMT) |
---|---|---|
committer | Senthil Kumaran <senthil@uthcode.com> | 2013-01-23 11:00:26 (GMT) |
commit | c1a7c565aaf1dfa573337bbc9a5222097252cf3b (patch) | |
tree | 6c1f886edf62c6c31157a7ef397a14295a2f7d1b /Lib/test/test_cgi.py | |
parent | 9427b0313346fc629d9b3f5e0134fbacb8533c06 (diff) | |
parent | 6b102f251f086feb058ed9aac8072bbafe362372 (diff) | |
download | cpython-c1a7c565aaf1dfa573337bbc9a5222097252cf3b.zip cpython-c1a7c565aaf1dfa573337bbc9a5222097252cf3b.tar.gz cpython-c1a7c565aaf1dfa573337bbc9a5222097252cf3b.tar.bz2 |
merge from 3.2
Issue #12411: Fix to cgi.parse_multipart to correctly use bytes boundaries and
bytes data. Patch by Jonas Wagner.
Diffstat (limited to 'Lib/test/test_cgi.py')
-rw-r--r-- | Lib/test/test_cgi.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py index 5510a0d..cb28aa8 100644 --- a/Lib/test/test_cgi.py +++ b/Lib/test/test_cgi.py @@ -5,6 +5,7 @@ import sys import tempfile import unittest import warnings +from collections import namedtuple from io import StringIO, BytesIO class HackedSysModule: @@ -119,6 +120,23 @@ def gen_result(data, environ): class CgiTests(unittest.TestCase): + def test_parse_multipart(self): + fp = BytesIO(POSTDATA.encode('latin1')) + env = {'boundary': BOUNDARY.encode('latin1'), + 'CONTENT-LENGTH': '558'} + result = cgi.parse_multipart(fp, env) + expected = {'submit': [b' Add '], 'id': [b'1234'], + 'file': [b'Testing 123.\n'], 'title': [b'']} + self.assertEqual(result, expected) + + def test_fieldstorage_properties(self): + fs = cgi.FieldStorage() + self.assertFalse(fs) + self.assertIn("FieldStorage", repr(fs)) + self.assertEqual(list(fs), list(fs.keys())) + fs.list.append(namedtuple('MockFieldStorage', 'name')('fieldvalue')) + self.assertTrue(fs) + def test_escape(self): # cgi.escape() is deprecated. with warnings.catch_warnings(): |