Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Lib/test/test_cookie.py

    r2 r391  
    11# Simple test suite for Cookie.py
    22
    3 from test.test_support import run_unittest, run_doctest
     3from test.test_support import run_unittest, run_doctest, check_warnings
    44import unittest
    55import Cookie
    66
    7 import warnings
    8 warnings.filterwarnings("ignore",
    9                         ".* class is insecure.*",
    10                         DeprecationWarning)
    117
    128class CookieTests(unittest.TestCase):
     
    5248        self.assertEqual(C.output(['path']),
    5349            'Set-Cookie: Customer="WILE_E_COYOTE"; Path=/acme')
    54         self.assertEqual(C.js_output(), """
     50        self.assertEqual(C.js_output(), r"""
    5551        <script type="text/javascript">
    5652        <!-- begin hiding
    57         document.cookie = "Customer="WILE_E_COYOTE"; Path=/acme; Version=1";
     53        document.cookie = "Customer=\"WILE_E_COYOTE\"; Path=/acme; Version=1";
    5854        // end hiding -->
    5955        </script>
    6056        """)
    61         self.assertEqual(C.js_output(['path']), """
     57        self.assertEqual(C.js_output(['path']), r"""
    6258        <script type="text/javascript">
    6359        <!-- begin hiding
    64         document.cookie = "Customer="WILE_E_COYOTE"; Path=/acme";
     60        document.cookie = "Customer=\"WILE_E_COYOTE\"; Path=/acme";
    6561        // end hiding -->
    6662        </script>
    6763        """)
     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"')
    6882
    6983    def test_quoted_meta(self):
     
    7791def test_main():
    7892    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)
    8097
    8198if __name__ == '__main__':
Note: See TracChangeset for help on using the changeset viewer.