Skip to content

Commit 944207e

Browse files
author
Rémi Lapeyre
committed
Move test in a new method
1 parent 6cde09b commit 944207e

1 file changed

Lines changed: 27 additions & 25 deletions

File tree

Lib/test/test_http_cookiejar.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,31 +1689,6 @@ def save_and_restore(cj, ignore_discard):
16891689
self.assertEqual(len(new_c), 4) # 2 of them discarded on save
16901690
self.assertIn("name='foo1', value='bar'", repr(new_c))
16911691

1692-
# Check compatibility with curl / wget cookiejar format.
1693-
# See issue 17164
1694-
try:
1695-
expires = int(time.time() + 3600)
1696-
with open(filename, "w") as f:
1697-
f.write(MozillaCookieJar.header)
1698-
f.write("www.foo.com\tFALSE\t/\tFALSE\t%u\tfoo1\tbar\n" %
1699-
expires)
1700-
f.write("www.foo.com\tFALSE\t/\tFALSE\t0\tfoo2\tbar\n")
1701-
f.write("www.foo.com\tFALSE\t/\tFALSE\t\tfoo3\tbar\n")
1702-
c = MozillaCookieJar()
1703-
c.revert(filename)
1704-
self.assertEqual(len(c), 1)
1705-
c.revert(filename, ignore_discard = True)
1706-
self.assertEqual(len(c), 3)
1707-
c.save(filename, ignore_discard = True)
1708-
with open(filename, "r") as f:
1709-
for line in f:
1710-
if line == '\n' or line.startswith('#'):
1711-
continue
1712-
self.assertRegex(line.split('\t')[4], '^\d+$')
1713-
finally:
1714-
try: os.unlink(filename)
1715-
except OSError: pass
1716-
17171692
def test_netscape_misc(self):
17181693
# Some additional Netscape cookies tests.
17191694
c = CookieJar()
@@ -1836,6 +1811,33 @@ def test_session_cookies(self):
18361811
# we didn't have session cookies in the first place
18371812
self.assertNotEqual(counter["session_before"], 0)
18381813

1814+
def test_curl_format(self):
1815+
# Check compatibility with curl / wget cookiejar format.
1816+
# See issue 17164
1817+
filename = test.support.TESTFN
1818+
try:
1819+
expires = int(time.time() + 3600)
1820+
with open(filename, "w") as f:
1821+
f.write(MozillaCookieJar.header)
1822+
f.write("www.foo.com\tFALSE\t/\tFALSE\t%u\tfoo1\tbar\n" %
1823+
expires)
1824+
f.write("www.foo.com\tFALSE\t/\tFALSE\t0\tfoo2\tbar\n")
1825+
f.write("www.foo.com\tFALSE\t/\tFALSE\t\tfoo3\tbar\n")
1826+
c = MozillaCookieJar()
1827+
c.revert(filename)
1828+
self.assertEqual(len(c), 1)
1829+
c.revert(filename, ignore_discard = True)
1830+
self.assertEqual(len(c), 3)
1831+
c.save(filename, ignore_discard = True)
1832+
with open(filename, "r") as f:
1833+
for line in f:
1834+
if line == '\n' or line.startswith('#'):
1835+
continue
1836+
self.assertRegex(line.split('\t')[4], '^\d+$')
1837+
finally:
1838+
try: os.unlink(filename)
1839+
except OSError: pass
1840+
18391841

18401842
def test_main(verbose=None):
18411843
test.support.run_unittest(

0 commit comments

Comments
 (0)