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

Method test_repr

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

Source from the content-addressed store, hash-verified

555 self.assertEqual(str(morsel_b), str(morsel_a))
556
557 def test_repr(self):
558 morsel = cookies.Morsel()
559 self.assertEqual(repr(morsel), '<Morsel: None=None>')
560 self.assertEqual(str(morsel), 'Set-Cookie: None=None')
561 morsel.set('key', 'val', 'coded_val')
562 self.assertEqual(repr(morsel), '<Morsel: key=coded_val>')
563 self.assertEqual(str(morsel), 'Set-Cookie: key=coded_val')
564 morsel.update({
565 'path': '/',
566 'comment': 'foo',
567 'domain': 'example.com',
568 'max-age': 0,
569 'secure': 0,
570 'version': 1,
571 })
572 self.assertEqual(repr(morsel),
573 '<Morsel: key=coded_val; Comment=foo; Domain=example.com; '
574 'Max-Age=0; Path=/; Version=1>')
575 self.assertEqual(str(morsel),
576 'Set-Cookie: key=coded_val; Comment=foo; Domain=example.com; '
577 'Max-Age=0; Path=/; Version=1')
578 morsel['secure'] = True
579 morsel['httponly'] = 1
580 self.assertEqual(repr(morsel),
581 '<Morsel: key=coded_val; Comment=foo; Domain=example.com; '
582 'HttpOnly; Max-Age=0; Path=/; Secure; Version=1>')
583 self.assertEqual(str(morsel),
584 'Set-Cookie: key=coded_val; Comment=foo; Domain=example.com; '
585 'HttpOnly; Max-Age=0; Path=/; Secure; Version=1')
586
587 morsel = cookies.Morsel()
588 morsel.set('key', 'val', 'coded_val')
589 morsel['expires'] = 0
590 self.assertRegex(repr(morsel),
591 r'<Morsel: key=coded_val; '
592 r'expires=\w+, \d+ \w+ \d+ \d+:\d+:\d+ \w+>')
593 self.assertRegex(str(morsel),
594 r'Set-Cookie: key=coded_val; '
595 r'expires=\w+, \d+ \w+ \d+ \d+:\d+:\d+ \w+')
596
597 def test_control_characters(self):
598 for c0 in support.control_characters_c0():

Callers

nothing calls this directly

Calls 5

setMethod · 0.95
updateMethod · 0.95
strFunction · 0.85
assertRegexMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected