(self)
| 1857 | cookie = interact_2965(c, "http://www.acme.com/\xfc") |
| 1858 | |
| 1859 | def test_mozilla(self): |
| 1860 | # Save / load Mozilla/Netscape cookie file format. |
| 1861 | year_plus_one = time.localtime()[0] + 1 |
| 1862 | |
| 1863 | filename = os_helper.TESTFN |
| 1864 | |
| 1865 | c = MozillaCookieJar(filename, |
| 1866 | policy=DefaultCookiePolicy(rfc2965=True)) |
| 1867 | interact_2965(c, "http://www.acme.com/", |
| 1868 | "foo1=bar; max-age=100; Version=1") |
| 1869 | interact_2965(c, "http://www.acme.com/", |
| 1870 | 'foo2=bar; port="80"; max-age=100; Discard; Version=1') |
| 1871 | interact_2965(c, "http://www.acme.com/", "foo3=bar; secure; Version=1") |
| 1872 | |
| 1873 | expires = "expires=09-Nov-%d 23:12:40 GMT" % (year_plus_one,) |
| 1874 | interact_netscape(c, "http://www.foo.com/", |
| 1875 | "fooa=bar; %s" % expires) |
| 1876 | interact_netscape(c, "http://www.foo.com/", |
| 1877 | "foob=bar; Domain=.foo.com; %s" % expires) |
| 1878 | interact_netscape(c, "http://www.foo.com/", |
| 1879 | "fooc=bar; Domain=www.foo.com; %s" % expires) |
| 1880 | |
| 1881 | for cookie in c: |
| 1882 | if cookie.name == "foo1": |
| 1883 | cookie.set_nonstandard_attr("HTTPOnly", "") |
| 1884 | |
| 1885 | def save_and_restore(cj, ignore_discard): |
| 1886 | try: |
| 1887 | cj.save(ignore_discard=ignore_discard) |
| 1888 | new_c = MozillaCookieJar(filename, |
| 1889 | DefaultCookiePolicy(rfc2965=True)) |
| 1890 | new_c.load(ignore_discard=ignore_discard) |
| 1891 | finally: |
| 1892 | os_helper.unlink(filename) |
| 1893 | return new_c |
| 1894 | |
| 1895 | new_c = save_and_restore(c, True) |
| 1896 | self.assertEqual(len(new_c), 6) # none discarded |
| 1897 | self.assertIn("name='foo1', value='bar'", repr(new_c)) |
| 1898 | self.assertIn("rest={'HTTPOnly': ''}", repr(new_c)) |
| 1899 | |
| 1900 | new_c = save_and_restore(c, False) |
| 1901 | self.assertEqual(len(new_c), 4) # 2 of them discarded on save |
| 1902 | self.assertIn("name='foo1', value='bar'", repr(new_c)) |
| 1903 | |
| 1904 | def test_netscape_misc(self): |
| 1905 | # Some additional Netscape cookies tests. |
nothing calls this directly
no test coverage detected