[Python-checkins] cpython (2.7): Adding test coverage for cgi.FieldStorage based on the scenario mentioned in

senthil.kumaran python-checkins at python.org
Sun Jan 12 07:22:32 CET 2014


http://hg.python.org/cpython/rev/2d6e7a5659f0
changeset: 88415:2d6e7a5659f0
branch: 2.7
parent: 88409:7dab4feec126
user: Senthil Kumaran <senthil at uthcode.com>
date: Sat Jan 11 22:16:55 2014 -0800
summary:
 Adding test coverage for cgi.FieldStorage based on the scenario mentioned in issue #19097
files:
 Lib/test/test_cgi.py | 10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py
--- a/Lib/test/test_cgi.py
+++ b/Lib/test/test_cgi.py
@@ -5,6 +5,8 @@
 import tempfile
 import unittest
 
+from collections import namedtuple
+
 class HackedSysModule:
 # The regression test will have real values in sys.argv, which
 # will completely confuse the test of the cgi module
@@ -232,6 +234,14 @@
 # as long as the chunksize is 1 << 16.
 self.assertTrue(f.numcalls > 2)
 
+ def test_fieldstorage_invalid(self):
+ fs = cgi.FieldStorage()
+ self.assertFalse(fs)
+ self.assertRaises(TypeError, bool(fs))
+ self.assertEqual(list(fs), list(fs.keys()))
+ fs.list.append(namedtuple('MockFieldStorage', 'name')('fieldvalue'))
+ self.assertTrue(fs)
+
 def test_fieldstorage_multipart(self):
 #Test basic FieldStorage multipart parsing
 env = {'REQUEST_METHOD':'POST', 'CONTENT_TYPE':'multipart/form-data; boundary=---------------------------721837373350705526688164684', 'CONTENT_LENGTH':'558'}
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /