Changeset 391 for python/trunk/Lib/test/test_cookie.py
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Lib/test/test_cookie.py
r2 r391 1 1 # Simple test suite for Cookie.py 2 2 3 from test.test_support import run_unittest, run_doctest 3 from test.test_support import run_unittest, run_doctest, check_warnings 4 4 import unittest 5 5 import Cookie 6 6 7 import warnings8 warnings.filterwarnings("ignore",9 ".* class is insecure.*",10 DeprecationWarning)11 7 12 8 class CookieTests(unittest.TestCase): … … 52 48 self.assertEqual(C.output(['path']), 53 49 'Set-Cookie: Customer="WILE_E_COYOTE"; Path=/acme') 54 self.assertEqual(C.js_output(), """50 self.assertEqual(C.js_output(), r""" 55 51 <script type="text/javascript"> 56 52 <!-- begin hiding 57 document.cookie = "Customer= "WILE_E_COYOTE"; Path=/acme; Version=1";53 document.cookie = "Customer=\"WILE_E_COYOTE\"; Path=/acme; Version=1"; 58 54 // end hiding --> 59 55 </script> 60 56 """) 61 self.assertEqual(C.js_output(['path']), """57 self.assertEqual(C.js_output(['path']), r""" 62 58 <script type="text/javascript"> 63 59 <!-- begin hiding 64 document.cookie = "Customer= "WILE_E_COYOTE"; Path=/acme";60 document.cookie = "Customer=\"WILE_E_COYOTE\"; Path=/acme"; 65 61 // end hiding --> 66 62 </script> 67 63 """) 64 65 # loading 'expires' 66 C = Cookie.SimpleCookie() 67 C.load('Customer="W"; expires=Wed, 01 Jan 2010 00:00:00 GMT') 68 self.assertEqual(C['Customer']['expires'], 69 'Wed, 01 Jan 2010 00:00:00 GMT') 70 C = Cookie.SimpleCookie() 71 C.load('Customer="W"; expires=Wed, 01 Jan 98 00:00:00 GMT') 72 self.assertEqual(C['Customer']['expires'], 73 'Wed, 01 Jan 98 00:00:00 GMT') 74 75 def test_extended_encode(self): 76 # Issue 9824: some browsers don't follow the standard; we now 77 # encode , and ; to keep them from tripping up. 78 C = Cookie.SimpleCookie() 79 C['val'] = "some,funky;stuff" 80 self.assertEqual(C.output(['val']), 81 'Set-Cookie: val="some\\054funky\\073stuff"') 68 82 69 83 def test_quoted_meta(self): … … 77 91 def test_main(): 78 92 run_unittest(CookieTests) 79 run_doctest(Cookie) 93 if Cookie.__doc__ is not None: 94 with check_warnings(('.+Cookie class is insecure; do not use it', 95 DeprecationWarning)): 96 run_doctest(Cookie) 80 97 81 98 if __name__ == '__main__':
Note:
See TracChangeset
for help on using the changeset viewer.