MCPcopy Index your code
hub / github.com/python/cpython / test_update

Method test_update

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

Source from the content-addressed store, hash-verified

514 self.assertNotIn('invalid', morsel)
515
516 def test_update(self):
517 attribs = {'expires': 1, 'Version': 2, 'DOMAIN': 'example.com'}
518 # test dict update
519 morsel = cookies.Morsel()
520 morsel.update(attribs)
521 self.assertEqual(morsel['expires'], 1)
522 self.assertEqual(morsel['version'], 2)
523 self.assertEqual(morsel['domain'], 'example.com')
524 # test iterable update
525 morsel = cookies.Morsel()
526 morsel.update(list(attribs.items()))
527 self.assertEqual(morsel['expires'], 1)
528 self.assertEqual(morsel['version'], 2)
529 self.assertEqual(morsel['domain'], 'example.com')
530 # test iterator update
531 morsel = cookies.Morsel()
532 morsel.update((k, v) for k, v in attribs.items())
533 self.assertEqual(morsel['expires'], 1)
534 self.assertEqual(morsel['version'], 2)
535 self.assertEqual(morsel['domain'], 'example.com')
536
537 with self.assertRaises(cookies.CookieError):
538 morsel.update({'invalid': 'value'})
539 self.assertNotIn('invalid', morsel)
540 self.assertRaises(TypeError, morsel.update)
541 self.assertRaises(TypeError, morsel.update, 0)
542
543 def test_pickle(self):
544 morsel_a = cookies.Morsel()

Callers

nothing calls this directly

Calls 6

updateMethod · 0.95
listClass · 0.85
assertNotInMethod · 0.80
assertEqualMethod · 0.45
itemsMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected