Skip to content

Commit

Permalink
Update sklearn tests to be compatible with current pytest version (py…
Browse files Browse the repository at this point in the history
…test >=8.0.0) (#3517)
  • Loading branch information
schlunma authored Feb 1, 2024
1 parent 7e9eecd commit 24d99df
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
# pylint: disable=too-few-public-methods
# pylint: disable=too-many-arguments

import warnings
from copy import copy, deepcopy

import numpy as np
Expand Down Expand Up @@ -504,9 +505,9 @@ def test_is_pairwise():
"""Test ``_is_pairwise``."""
# Simple checks for _is_pairwise
pca = KernelPCA(kernel='precomputed')
with pytest.warns(None) as record:
with warnings.catch_warnings():
warnings.simplefilter("error") # make sure that no warning is raised
assert _is_pairwise(pca)
assert not record

# Pairwise attribute that is not consistent with the pairwise tag
class IncorrectTagPCA(KernelPCA):
Expand All @@ -532,9 +533,9 @@ class TruePairwise(BaseEstimator):

# Pairwise attribute is not defined thus tag is used
est = BaseEstimator()
with pytest.warns(None) as record:
with warnings.catch_warnings():
warnings.simplefilter("error") # make sure that no warning is raised
assert not _is_pairwise(est)
assert not record


# _safe_split
Expand Down

0 comments on commit 24d99df

Please sign in to comment.