(self)
| 639 | morsel |= {c0: "val"} |
| 640 | |
| 641 | def test_control_characters_output(self): |
| 642 | # Tests that even if the internals of Morsel are modified |
| 643 | # that a call to .output() has control character safeguards. |
| 644 | for c0 in support.control_characters_c0(): |
| 645 | morsel = cookies.Morsel() |
| 646 | morsel.set("key", "value", "coded-value") |
| 647 | morsel._key = c0 # Override private variable. |
| 648 | cookie = cookies.SimpleCookie() |
| 649 | cookie["cookie"] = morsel |
| 650 | with self.assertRaises(cookies.CookieError): |
| 651 | cookie.output() |
| 652 | |
| 653 | morsel = cookies.Morsel() |
| 654 | morsel.set("key", "value", "coded-value") |
| 655 | morsel._coded_value = c0 # Override private variable. |
| 656 | cookie = cookies.SimpleCookie() |
| 657 | cookie["cookie"] = morsel |
| 658 | with self.assertRaises(cookies.CookieError): |
| 659 | cookie.output() |
| 660 | |
| 661 | # Tests that .js_output() also has control character safeguards. |
| 662 | for c0 in support.control_characters_c0(): |
| 663 | morsel = cookies.Morsel() |
| 664 | morsel.set("key", "value", "coded-value") |
| 665 | morsel._key = c0 # Override private variable. |
| 666 | cookie = cookies.SimpleCookie() |
| 667 | cookie["cookie"] = morsel |
| 668 | with self.assertRaises(cookies.CookieError): |
| 669 | cookie.js_output() |
| 670 | |
| 671 | morsel = cookies.Morsel() |
| 672 | morsel.set("key", "value", "coded-value") |
| 673 | morsel._coded_value = c0 # Override private variable. |
| 674 | cookie = cookies.SimpleCookie() |
| 675 | cookie["cookie"] = morsel |
| 676 | with self.assertRaises(cookies.CookieError): |
| 677 | cookie.js_output() |
| 678 | |
| 679 | |
| 680 | def load_tests(loader, tests, pattern): |
nothing calls this directly
no test coverage detected