@ -168,11 +168,12 @@ class TestISO639_1(unittest.TestCase):
class TestCookiesTxt ( unittest . TestCase ) :
class TestCookiesTxt ( unittest . TestCase ) :
def test_ load_ cookiestxt( self ) :
def test_ cookiestxt_load ( self ) :
def _assert ( content , expected ) :
def _assert ( content , expected ) :
cookies = util . load_cookiestxt ( io . StringIO ( content , None ) )
jar = http . cookiejar . CookieJar ( )
for c , e in zip ( cookies , expected ) :
util . cookiestxt_load ( io . StringIO ( content , None ) , jar )
for c , e in zip ( jar , expected ) :
self . assertEqual ( c . __dict__ , e . __dict__ )
self . assertEqual ( c . __dict__ , e . __dict__ )
_assert ( " " , [ ] )
_assert ( " " , [ ] )
@ -218,13 +219,14 @@ class TestCookiesTxt(unittest.TestCase):
)
)
with self . assertRaises ( ValueError ) :
with self . assertRaises ( ValueError ) :
util . load_cookiestxt ( " example.org \t TRUE \t / \t TRUE \t 0 \t name " )
util . cookiestxt_load ( " example.org \t TRUE \t / \t TRUE \t 0 \t name " ,
http . cookiejar . CookieJar ( ) )
def test_ save_ cookiestxt( self ) :
def test_ cookiestxt_store ( self ) :
def _assert ( cookies , expected ) :
def _assert ( cookies , expected ) :
fp = io . StringIO ( newline = None )
fp = io . StringIO ( newline = None )
util . save_ cookiestxt( fp , cookies )
util . cookiestxt_store ( fp , cookies )
self . assertMultiLineEqual ( fp . getvalue ( ) , expected )
self . assertMultiLineEqual ( fp . getvalue ( ) , expected )
_assert ( [ ] , " # Netscape HTTP Cookie File \n \n " )
_assert ( [ ] , " # Netscape HTTP Cookie File \n \n " )