~ubuntu-branches/ubuntu/oneiric/python2.6/oneiric

« back to all changes in this revision

Viewing changes to Lib/test/test_cookie.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-08-07 20:03:08 UTC
  • mfrom: (10.1.27 sid)
  • Revision ID: james.westby@ubuntu.com-20100807200308-bwsyymoc4donr9a9
Tags: 2.6.6~rc1-1ubuntu1
* Merge with Debian; remaining changes:
  - Regenerate the control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 warnings
8
 
warnings.filterwarnings("ignore",
9
 
                        ".* class is insecure.*",
10
 
                        DeprecationWarning)
11
7
 
12
8
class CookieTests(unittest.TestCase):
13
9
    # Currently this only tests SimpleCookie
66
62
        </script>
67
63
        """)
68
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
 
69
75
    def test_quoted_meta(self):
70
76
        # Try cookie with quoted meta-data
71
77
        C = Cookie.SimpleCookie()
76
82
 
77
83
def test_main():
78
84
    run_unittest(CookieTests)
79
 
    run_doctest(Cookie)
 
85
    with check_warnings(('.+Cookie class is insecure; do not use it',
 
86
                         DeprecationWarning)):
 
87
        run_doctest(Cookie)
80
88
 
81
89
if __name__ == '__main__':
82
90
    test_main()