MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_setter

Method test_setter

Lib/test/test_http_cookies.py:354–383  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

352 M.__setitem__, i, '%s_value' % i)
353
354 def test_setter(self):
355 M = cookies.Morsel()
356 # tests the .set method to set keys and their values
357 for i in M._reserved:
358 # Makes sure that all reserved keys can't be set this way
359 self.assertRaises(cookies.CookieError,
360 M.set, i, '%s_value' % i, '%s_value' % i)
361 for i in "thou cast _the- !holy! ^hand| +*grenade~".split():
362 # Try typical use case. Setting decent values.
363 # Check output and js_output.
364 M['path'] = '/foo' # Try a reserved key as well
365 M.set(i, "%s_val" % i, "%s_coded_val" % i)
366 self.assertEqual(M.key, i)
367 self.assertEqual(M.value, "%s_val" % i)
368 self.assertEqual(M.coded_value, "%s_coded_val" % i)
369 self.assertEqual(
370 M.output(),
371 "Set-Cookie: %s=%s; Path=/foo" % (i, "%s_coded_val" % i))
372 expected_js_output = """
373 <script type="text/javascript">
374 <!-- begin hiding
375 document.cookie = "%s=%s; Path=/foo";
376 // end hiding -->
377 </script>
378 """ % (i, "%s_coded_val" % i)
379 self.assertEqual(M.js_output(), expected_js_output)
380 for i in ["foo bar", "foo@bar"]:
381 # Try some illegal characters
382 self.assertRaises(cookies.CookieError,
383 M.set, i, '%s_value' % i, '%s_value' % i)
384
385 def test_set_properties(self):
386 morsel = cookies.Morsel()

Callers

nothing calls this directly

Calls 6

setMethod · 0.95
outputMethod · 0.95
js_outputMethod · 0.95
assertRaisesMethod · 0.45
splitMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected