mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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.
This commit is contained in:
parent
5636eb7b93
commit
b4cbb92fbe
3 changed files with 22 additions and 2 deletions
|
@ -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():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue