def test_1():
with pytest.warns(DeprecationWarning) as records:
warnings.simplefilter('ignore')
print('warnings.warn is ', warnings.warn.__module__)
print('filters', warnings.filters)
filterwarnings('default', category=DeprecationWarning,
emodule='examples.dependency')
filterwarnings('ignore', category=DeprecationWarning,
emodule='examples.dependency.bar')
consumer()
for r in records.list:
print('Record :', r.message, 'In file', r.filename)
assert len(records) == 1
评论列表
文章目录