Back to index

python3.2  3.2.2
Public Member Functions
test.test_http_cookiejar.FileCookieJarTests Class Reference

List of all members.

Public Member Functions

def test_lwp_valueless_cookie
def test_bad_magic

Detailed Description

Definition at line 234 of file test_http_cookiejar.py.


Member Function Documentation

Definition at line 250 of file test_http_cookiejar.py.

00250 
00251     def test_bad_magic(self):
00252         # IOErrors (eg. file doesn't exist) are allowed to propagate
00253         filename = test.support.TESTFN
00254         for cookiejar_class in LWPCookieJar, MozillaCookieJar:
00255             c = cookiejar_class()
00256             try:
00257                 c.load(filename="for this test to work, a file with this "
00258                                 "filename should not exist")
00259             except IOError as exc:
00260                 # exactly IOError, not LoadError
00261                 self.assertIs(exc.__class__, IOError)
00262             else:
00263                 self.fail("expected IOError for invalid filename")
00264         # Invalid contents of cookies file (eg. bad magic string)
00265         # causes a LoadError.
00266         try:
00267             with open(filename, "w") as f:
00268                 f.write("oops\n")
00269                 for cookiejar_class in LWPCookieJar, MozillaCookieJar:
00270                     c = cookiejar_class()
00271                     self.assertRaises(LoadError, c.load, filename)
00272         finally:
00273             try: os.unlink(filename)
00274             except OSError: pass

Here is the call graph for this function:

Definition at line 235 of file test_http_cookiejar.py.

00235 
00236     def test_lwp_valueless_cookie(self):
00237         # cookies with no value should be saved and loaded consistently
00238         filename = test.support.TESTFN
00239         c = LWPCookieJar()
00240         interact_netscape(c, "http://www.acme.com/", 'boo')
00241         self.assertEqual(c._cookies["www.acme.com"]["/"]["boo"].value, None)
00242         try:
00243             c.save(filename, ignore_discard=True)
00244             c = LWPCookieJar()
00245             c.load(filename, ignore_discard=True)
00246         finally:
00247             try: os.unlink(filename)
00248             except OSError: pass
00249         self.assertEqual(c._cookies["www.acme.com"]["/"]["boo"].value, None)

Here is the call graph for this function:


The documentation for this class was generated from the following file: