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

Method test_repr

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

Source from the content-addressed store, hash-verified

533 self.assertEqual(str(morsel_b), str(morsel_a))
534
535 def test_repr(self):
536 morsel = cookies.Morsel()
537 self.assertEqual(repr(morsel), '<Morsel: None=None>')
538 self.assertEqual(str(morsel), 'Set-Cookie: None=None')
539 morsel.set('key', 'val', 'coded_val')
540 self.assertEqual(repr(morsel), '<Morsel: key=coded_val>')
541 self.assertEqual(str(morsel), 'Set-Cookie: key=coded_val')
542 morsel.update({
543 'path': '/',
544 'comment': 'foo',
545 'domain': 'example.com',
546 'max-age': 0,
547 'secure': 0,
548 'version': 1,
549 })
550 self.assertEqual(repr(morsel),
551 '<Morsel: key=coded_val; Comment=foo; Domain=example.com; '
552 'Max-Age=0; Path=/; Version=1>')
553 self.assertEqual(str(morsel),
554 'Set-Cookie: key=coded_val; Comment=foo; Domain=example.com; '
555 'Max-Age=0; Path=/; Version=1')
556 morsel['secure'] = True
557 morsel['httponly'] = 1
558 self.assertEqual(repr(morsel),
559 '<Morsel: key=coded_val; Comment=foo; Domain=example.com; '
560 'HttpOnly; Max-Age=0; Path=/; Secure; Version=1>')
561 self.assertEqual(str(morsel),
562 'Set-Cookie: key=coded_val; Comment=foo; Domain=example.com; '
563 'HttpOnly; Max-Age=0; Path=/; Secure; Version=1')
564
565 morsel = cookies.Morsel()
566 morsel.set('key', 'val', 'coded_val')
567 morsel['expires'] = 0
568 self.assertRegex(repr(morsel),
569 r'<Morsel: key=coded_val; '
570 r'expires=\w+, \d+ \w+ \d+ \d+:\d+:\d+ \w+>')
571 self.assertRegex(str(morsel),
572 r'Set-Cookie: key=coded_val; '
573 r'expires=\w+, \d+ \w+ \d+ \d+:\d+:\d+ \w+')
574
575 def test_control_characters(self):
576 for c0 in support.control_characters_c0():

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected