diff --git a/sklearn/datasets/tests/test_openml.py b/sklearn/datasets/tests/test_openml.py index 9f55909c6643b..dac0762eb2160 100644 --- a/sklearn/datasets/tests/test_openml.py +++ b/sklearn/datasets/tests/test_openml.py @@ -772,15 +772,12 @@ def test_fetch_openml_iris(monkeypatch, gzip_response): data_name = 'iris' _monkey_patch_webbased_functions(monkeypatch, data_id, gzip_response) - assert_warns_message( - UserWarning, - "Multiple active versions of the dataset matching the name" - " iris exist. Versions may be fundamentally different, " - "returning version 1.", - fetch_openml, - name=data_name, - as_frame=False - ) + + msg = ("Multiple active versions of the dataset matching the name" + " iris exist. Versions may be fundamentally different, " + "returning version 1.") + with pytest.warns(UserWarning, match=msg): + fetch_openml(name=data_name, as_frame=False, cache=False) def test_decode_iris(monkeypatch):