@@ -1294,17 +1294,23 @@ def test_clear_and_catch_warnings():
1294
1294
warnings .simplefilter ('ignore' )
1295
1295
warnings .warn ('Some warning' )
1296
1296
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'.
1298
1299
with clear_and_catch_warnings ():
1299
1300
warnings .simplefilter ('ignore' )
1300
1301
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
+
1302
1308
# Confirm that specifying module keeps old warning, does not add new
1303
1309
with clear_and_catch_warnings (modules = [my_mod ]):
1304
1310
warnings .simplefilter ('ignore' )
1305
1311
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
1308
1314
with clear_and_catch_warnings ():
1309
1315
warnings .simplefilter ('ignore' )
1310
1316
warnings .warn ('Another warning' )
@@ -1350,11 +1356,15 @@ def warn(arr):
1350
1356
warnings .warn ('Some warning' )
1351
1357
assert_warn_len_equal (my_mod , 0 )
1352
1358
1359
+ # Manually adding two warnings to the registry:
1360
+ my_mod .__warningregistry__ = {'warning1' : 1 ,
1361
+ 'warning2' : 2 }
1362
+
1353
1363
# Without specified modules, don't clear warnings during context
1354
1364
with suppress_warnings ():
1355
1365
warnings .simplefilter ('ignore' )
1356
1366
warnings .warn ('Some warning' )
1357
- assert_warn_len_equal (my_mod , 1 )
1367
+ assert_warn_len_equal (my_mod , 2 )
1358
1368
1359
1369
1360
1370
def test_suppress_warnings_type ():
@@ -1378,11 +1388,15 @@ def test_suppress_warnings_type():
1378
1388
warnings .warn ('Some warning' )
1379
1389
assert_warn_len_equal (my_mod , 0 )
1380
1390
1391
+ # Manually adding two warnings to the registry:
1392
+ my_mod .__warningregistry__ = {'warning1' : 1 ,
1393
+ 'warning2' : 2 }
1394
+
1381
1395
# Without specified modules, don't clear warnings during context
1382
1396
with suppress_warnings ():
1383
1397
warnings .simplefilter ('ignore' )
1384
1398
warnings .warn ('Some warning' )
1385
- assert_warn_len_equal (my_mod , 1 )
1399
+ assert_warn_len_equal (my_mod , 2 )
1386
1400
1387
1401
1388
1402
def test_suppress_warnings_decorate_no_record ():
0 commit comments