mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Update test_http_cookies.py from 3.14.3
This commit is contained in:
1 parent
6cf3cc7715
commit
3acab100f4
1 file changed
+38
Vendored
+38
@@ -582,6 +582,14 @@ class MorselTests(unittest.TestCase):
|
||||
with self.assertRaises(cookies.CookieError):
|
||||
morsel["path"] = c0
|
||||
|
||||
# .__setstate__()
|
||||
with self.assertRaises(cookies.CookieError):
|
||||
morsel.__setstate__({'key': c0, 'value': 'val', 'coded_value': 'coded'})
|
||||
with self.assertRaises(cookies.CookieError):
|
||||
morsel.__setstate__({'key': 'key', 'value': c0, 'coded_value': 'coded'})
|
||||
with self.assertRaises(cookies.CookieError):
|
||||
morsel.__setstate__({'key': 'key', 'value': 'val', 'coded_value': c0})
|
||||
|
||||
# .setdefault()
|
||||
with self.assertRaises(cookies.CookieError):
|
||||
morsel.setdefault("path", c0)
|
||||
@@ -596,6 +604,18 @@ class MorselTests(unittest.TestCase):
|
||||
with self.assertRaises(cookies.CookieError):
|
||||
morsel.set("path", "val", c0)
|
||||
|
||||
# .update()
|
||||
with self.assertRaises(cookies.CookieError):
|
||||
morsel.update({"path": c0})
|
||||
with self.assertRaises(cookies.CookieError):
|
||||
morsel.update({c0: "val"})
|
||||
|
||||
# .__ior__()
|
||||
with self.assertRaises(cookies.CookieError):
|
||||
morsel |= {"path": c0}
|
||||
with self.assertRaises(cookies.CookieError):
|
||||
morsel |= {c0: "val"}
|
||||
|
||||
def test_control_characters_output(self):
|
||||
# Tests that even if the internals of Morsel are modified
|
||||
# that a call to .output() has control character safeguards.
|
||||
@@ -616,6 +636,24 @@ class MorselTests(unittest.TestCase):
|
||||
with self.assertRaises(cookies.CookieError):
|
||||
cookie.output()
|
||||
|
||||
# Tests that .js_output() also has control character safeguards.
|
||||
for c0 in support.control_characters_c0():
|
||||
morsel = cookies.Morsel()
|
||||
morsel.set("key", "value", "coded-value")
|
||||
morsel._key = c0 # Override private variable.
|
||||
cookie = cookies.SimpleCookie()
|
||||
cookie["cookie"] = morsel
|
||||
with self.assertRaises(cookies.CookieError):
|
||||
cookie.js_output()
|
||||
|
||||
morsel = cookies.Morsel()
|
||||
morsel.set("key", "value", "coded-value")
|
||||
morsel._coded_value = c0 # Override private variable.
|
||||
cookie = cookies.SimpleCookie()
|
||||
cookie["cookie"] = morsel
|
||||
with self.assertRaises(cookies.CookieError):
|
||||
cookie.js_output()
|
||||
|
||||
|
||||
def load_tests(loader, tests, pattern):
|
||||
tests.addTest(doctest.DocTestSuite(cookies))
|
||||
|
||||
Reference in new issue
Block a user