@@ -686,6 +686,34 @@ async def make_jar():
686686 self .assertEqual (len (jar_filtered ), 1 )
687687 self .assertEqual (jar_filtered ["path-cookie" ].value , "one" )
688688
689+ def test_filter_cookies_order_by_path (self ) -> None :
690+ async def make_jar ():
691+ return CookieJar (unsafe = True )
692+
693+ jar = self .loop .run_until_complete (make_jar ())
694+ jar .update_cookies (
695+ SimpleCookie ("path-cookie=one; Domain=pathtest.com; Path=/one; " )
696+ )
697+ jar .update_cookies (
698+ SimpleCookie ("path-cookie=zero; Domain=pathtest.com; Path=/; " )
699+ )
700+ jar .update_cookies (
701+ SimpleCookie ("path-cookie=two; Domain=pathtest.com; Path=/second; " )
702+ )
703+ self .assertEqual (len (jar ), 3 )
704+
705+ jar_filtered = jar .filter_cookies (URL ("http://pathtest.com/" ))
706+ self .assertEqual (len (jar_filtered ), 1 )
707+ self .assertEqual (jar_filtered ["path-cookie" ].value , "zero" )
708+
709+ jar_filtered = jar .filter_cookies (URL ("http://pathtest.com/second" ))
710+ self .assertEqual (len (jar_filtered ), 1 )
711+ self .assertEqual (jar_filtered ["path-cookie" ].value , "two" )
712+
713+ jar_filtered = jar .filter_cookies (URL ("http://pathtest.com/one" ))
714+ self .assertEqual (len (jar_filtered ), 1 )
715+ self .assertEqual (jar_filtered ["path-cookie" ].value , "one" )
716+
689717
690718async def test_dummy_cookie_jar () -> None :
691719 cookie = SimpleCookie ("foo=bar; Domain=example.com;" )
0 commit comments