summaryrefslogtreecommitdiff
path: root/Lib/test/test_cgi.py
diff options
context:
space:
mode:
authorSenthil Kumaran <senthil@uthcode.com>2014-01-11 22:20:16 -0800
committerSenthil Kumaran <senthil@uthcode.com>2014-01-11 22:20:16 -0800
commitb4cbb92fbe6290c3574e73288de9e9cbb60b7688 (patch)
tree9714adc7666487a741be49eb94bb81bfb9b87365 /Lib/test/test_cgi.py
parent5636eb7b93cb1364fb099f77fc43de75aef658fc (diff)
downloadcpython-git-b4cbb92fbe6290c3574e73288de9e9cbb60b7688.tar.gz
Issue #19092 - Raise a correct exception when cgi.FieldStorage is given an
invalid file-obj. Also use __bool__ to determine the bool of the FieldStorage object.
Diffstat (limited to 'Lib/test/test_cgi.py')
-rw-r--r--Lib/test/test_cgi.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py
index d80ec07767..e604c926b9 100644
--- a/Lib/test/test_cgi.py
+++ b/Lib/test/test_cgi.py
@@ -137,6 +137,13 @@ class CgiTests(unittest.TestCase):
fs.list.append(namedtuple('MockFieldStorage', 'name')('fieldvalue'))
self.assertTrue(fs)
+ def test_fieldstorage_invalid(self):
+ self.assertRaises(TypeError, cgi.FieldStorage, "not-a-file-obj",
+ environ={"REQUEST_METHOD":"PUT"})
+ self.assertRaises(TypeError, cgi.FieldStorage, "foo", "bar")
+ fs = cgi.FieldStorage(headers={'content-type':'text/plain'})
+ self.assertRaises(TypeError, bool, fs)
+
def test_escape(self):
# cgi.escape() is deprecated.
with warnings.catch_warnings():