Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: Replace use of pytest.warns(None) with warnings.catch_warnings #15192

Merged
merged 1 commit into from Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions scipy/fft/tests/test_fftlog.py
@@ -1,3 +1,4 @@
import warnings
import numpy as np
from numpy.testing import assert_allclose
import pytest
Expand Down Expand Up @@ -108,13 +109,13 @@ def test_fht_special_cases():

# case 1: xp in M, xm in M => well-defined transform
mu, bias = -4.0, 1.0
with pytest.warns(None) as record:
with warnings.catch_warnings(record=True) as record:
fht(a, dln, mu, bias=bias)
assert not record, 'fht warned about a well-defined transform'

# case 2: xp not in M, xm in M => well-defined transform
mu, bias = -2.5, 0.5
with pytest.warns(None) as record:
with warnings.catch_warnings(record=True) as record:
fht(a, dln, mu, bias=bias)
assert not record, 'fht warned about a well-defined transform'

Expand Down
5 changes: 4 additions & 1 deletion scipy/sparse/csgraph/tests/test_shortest_path.py
@@ -1,3 +1,4 @@
import warnings
import numpy as np
from numpy.testing import assert_array_almost_equal, assert_array_equal
from pytest import raises as assert_raises
Expand Down Expand Up @@ -118,6 +119,7 @@ def check(method, directed_in):
for directed_in in (True, False):
check(method, directed_in)


def test_directed_sparse_zero():
# test directed sparse graph with zero-weight edge and two connected components
def check(method):
Expand All @@ -128,6 +130,7 @@ def check(method):
for method in methods:
check(method)


def test_undirected_sparse_zero():
def check(method, directed_in):
if directed_in:
Expand Down Expand Up @@ -312,7 +315,7 @@ def test_buffer(method):


def test_NaN_warnings():
with pytest.warns(None) as record:
with warnings.catch_warnings(record=True) as record:
shortest_path(np.array([[0, 1], [np.nan, 0]]))
for r in record:
assert r.category is not RuntimeWarning
Expand Down