@@ -1294,17 +1294,23 @@ def test_clear_and_catch_warnings():
12941294 warnings .simplefilter ('ignore' )
12951295 warnings .warn ('Some warning' )
12961296 assert_equal (my_mod .__warningregistry__ , {})
1297- # Without specified modules, don't clear warnings during context
1297+ # Without specified modules, don't clear warnings during context.
1298+ # catch_warnings doesn't make an entry for 'ignore'.
12981299 with clear_and_catch_warnings ():
12991300 warnings .simplefilter ('ignore' )
13001301 warnings .warn ('Some warning' )
1301- assert_warn_len_equal (my_mod , 1 )
1302+ assert_warn_len_equal (my_mod , 0 )
1303+
1304+ # Manually adding two warnings to the registry:
1305+ my_mod .__warningregistry__ = {'warning1' : 1 ,
1306+ 'warning2' : 2 }
1307+
13021308 # Confirm that specifying module keeps old warning, does not add new
13031309 with clear_and_catch_warnings (modules = [my_mod ]):
13041310 warnings .simplefilter ('ignore' )
13051311 warnings .warn ('Another warning' )
1306- assert_warn_len_equal (my_mod , 1 )
1307- # Another warning, no module spec does add to warnings dict, except on
1312+ assert_warn_len_equal (my_mod , 2 )
1313+ # Another warning, no module spec does add to warnings dict
13081314 with clear_and_catch_warnings ():
13091315 warnings .simplefilter ('ignore' )
13101316 warnings .warn ('Another warning' )
@@ -1350,11 +1356,15 @@ def warn(arr):
13501356 warnings .warn ('Some warning' )
13511357 assert_warn_len_equal (my_mod , 0 )
13521358
1359+ # Manually adding two warnings to the registry:
1360+ my_mod .__warningregistry__ = {'warning1' : 1 ,
1361+ 'warning2' : 2 }
1362+
13531363 # Without specified modules, don't clear warnings during context
13541364 with suppress_warnings ():
13551365 warnings .simplefilter ('ignore' )
13561366 warnings .warn ('Some warning' )
1357- assert_warn_len_equal (my_mod , 1 )
1367+ assert_warn_len_equal (my_mod , 2 )
13581368
13591369
13601370def test_suppress_warnings_type ():
@@ -1378,11 +1388,15 @@ def test_suppress_warnings_type():
13781388 warnings .warn ('Some warning' )
13791389 assert_warn_len_equal (my_mod , 0 )
13801390
1391+ # Manually adding two warnings to the registry:
1392+ my_mod .__warningregistry__ = {'warning1' : 1 ,
1393+ 'warning2' : 2 }
1394+
13811395 # Without specified modules, don't clear warnings during context
13821396 with suppress_warnings ():
13831397 warnings .simplefilter ('ignore' )
13841398 warnings .warn ('Some warning' )
1385- assert_warn_len_equal (my_mod , 1 )
1399+ assert_warn_len_equal (my_mod , 2 )
13861400
13871401
13881402def test_suppress_warnings_decorate_no_record ():
0 commit comments