diff options
author | Senthil Kumaran <senthil@uthcode.com> | 2014-01-11 22:20:16 -0800 |
---|---|---|
committer | Senthil Kumaran <senthil@uthcode.com> | 2014-01-11 22:20:16 -0800 |
commit | 49596f31076d37c972d023cc277441a592653419 (patch) | |
tree | 000cdbba42c50195754daa72f71fa70f3eb6d4fb /Lib/test/test_cgi.py | |
parent | 606e946bdde6fd9c3795bff32ad981471f2c47cb (diff) | |
download | cpython-49596f31076d37c972d023cc277441a592653419.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.py | 7 |
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(): |