@@ -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\t FALSE\t /\t FALSE\t %u\t foo1\t bar\n " %
1699- expires )
1700- f .write ("www.foo.com\t FALSE\t /\t FALSE\t 0\t foo2\t bar\n " )
1701- f .write ("www.foo.com\t FALSE\t /\t FALSE\t \t foo3\t bar\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\t FALSE\t /\t FALSE\t %u\t foo1\t bar\n " %
1823+ expires )
1824+ f .write ("www.foo.com\t FALSE\t /\t FALSE\t 0\t foo2\t bar\n " )
1825+ f .write ("www.foo.com\t FALSE\t /\t FALSE\t \t foo3\t bar\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
18401842def test_main (verbose = None ):
18411843 test .support .run_unittest (
0 commit comments