@@ -176,7 +176,7 @@ def test_load(self):
176176 self .assertEqual (C .output (['path' ]),
177177 'Set-Cookie: Customer="WILE_E_COYOTE"; Path=/acme' )
178178 cookie_encoded = base64 .b64encode (b'Customer="WILE_E_COYOTE"; Path=/acme; Version=1' ).decode ('ascii' )
179- with self .assertWarnsRegex (DeprecationWarning , r"Morsel \.js_output" ):
179+ with self .assertWarnsRegex (DeprecationWarning , r"BaseCookie \.js_output" ):
180180 self .assertEqual (C .js_output (), fr"""
181181 <script type="text/javascript">
182182 <!-- begin hiding
@@ -185,7 +185,7 @@ def test_load(self):
185185 </script>
186186 """ )
187187 cookie_encoded = base64 .b64encode (b'Customer="WILE_E_COYOTE"; Path=/acme' ).decode ('ascii' )
188- with self .assertWarnsRegex (DeprecationWarning , r"Morsel \.js_output" ):
188+ with self .assertWarnsRegex (DeprecationWarning , r"BaseCookie \.js_output" ):
189189 self .assertEqual (C .js_output (['path' ]), fr"""
190190 <script type="text/javascript">
191191 <!-- begin hiding
@@ -295,7 +295,7 @@ def test_quoted_meta(self):
295295 self .assertEqual (C .output (['path' ]),
296296 'Set-Cookie: Customer="WILE_E_COYOTE"; Path=/acme' )
297297 expected_encoded_cookie = base64 .b64encode (b'Customer=\" WILE_E_COYOTE\" ; Path=/acme; Version=1' ).decode ('ascii' )
298- with self .assertWarnsRegex (DeprecationWarning , r"Morsel \.js_output" ):
298+ with self .assertWarnsRegex (DeprecationWarning , r"BaseCookie \.js_output" ):
299299 self .assertEqual (C .js_output (), fr"""
300300 <script type="text/javascript">
301301 <!-- begin hiding
@@ -304,7 +304,7 @@ def test_quoted_meta(self):
304304 </script>
305305 """ )
306306 expected_encoded_cookie = base64 .b64encode (b'Customer=\" WILE_E_COYOTE\" ; Path=/acme' ).decode ('ascii' )
307- with self .assertWarnsRegex (DeprecationWarning , r"Morsel \.js_output" ):
307+ with self .assertWarnsRegex (DeprecationWarning , r"BaseCookie \.js_output" ):
308308 self .assertEqual (C .js_output (['path' ]), fr"""
309309 <script type="text/javascript">
310310 <!-- begin hiding
@@ -693,21 +693,23 @@ def test_control_characters_output(self):
693693 def test_morsel_js_output_deprecated (self ):
694694 morsel = cookies .Morsel ()
695695 morsel .set ("key" , "value" , "value" )
696- with self .assertWarnsRegex (DeprecationWarning , r"Morsel\.js_output" ):
696+ with self .assertWarnsRegex (DeprecationWarning , r"Morsel\.js_output" ) as cm :
697697 result = morsel .js_output ()
698+ self .assertEqual (cm .filename , __file__ )
698699 self .assertIn ("document.cookie" , result )
699700
701+
700702 def test_basecookie_js_output_warns_once (self ):
701703 C = cookies .SimpleCookie ()
702704 C ["key" ] = "value"
703705 with self .assertWarns (DeprecationWarning ) as cm :
704706 C .js_output ()
705- # Should only be one warning even though BaseCookie iterates Morsels
706707 deprecation_warnings = [
707708 w for w in cm .warnings if issubclass (w .category , DeprecationWarning )
708709 ]
709710 self .assertEqual (len (deprecation_warnings ), 1 )
710- self .assertRegex (str (deprecation_warnings [0 ].message ), r"Morsel\.js_output" )
711+ self .assertRegex (str (deprecation_warnings [0 ].message ), r"BaseCookie\.js_output" )
712+ self .assertEqual (cm .filename , __file__ )
711713
712714def load_tests (loader , tests , pattern ):
713715 tests .addTest (doctest .DocTestSuite (cookies ))
0 commit comments