Skip to content

Commit ac8e697

Browse files
committed
tests: skip tests if sklearn data not available
1 parent 9f3a35b commit ac8e697

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

tests/test_classification_krige.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,13 @@ def test_krige_classification_housing():
6969

7070
try:
7171
housing = fetch_california_housing()
72-
except (ssl.SSLError, urllib.error.URLError):
73-
ssl._create_default_https_context = ssl._create_unverified_context
74-
try:
75-
housing = fetch_california_housing()
76-
except PermissionError:
77-
# This can raise permission error on Appveyor
78-
pytest.skip("Failed to load california housing dataset")
79-
ssl._create_default_https_context = ssl.create_default_context
72+
except (
73+
ssl.SSLError,
74+
urllib.error.URLError,
75+
urllib.error.HTTPError,
76+
PermissionError,
77+
):
78+
pytest.skip("Failed to load california housing dataset")
8079

8180
# take only first 1000
8281
p = housing["data"][:1000, :-2]

tests/test_regression_krige.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,13 @@ def test_krige_housing():
6969

7070
try:
7171
housing = fetch_california_housing()
72-
except (ssl.SSLError, urllib.error.URLError):
73-
ssl._create_default_https_context = ssl._create_unverified_context
74-
try:
75-
housing = fetch_california_housing()
76-
except PermissionError:
77-
# This can raise permission error on Appveyor
78-
pytest.skip("Failed to load california housing dataset")
79-
ssl._create_default_https_context = ssl.create_default_context
72+
except (
73+
ssl.SSLError,
74+
urllib.error.URLError,
75+
urllib.error.HTTPError,
76+
PermissionError,
77+
):
78+
pytest.skip("Failed to load california housing dataset")
8079

8180
# take only first 1000
8281
p = housing["data"][:1000, :-2]

0 commit comments

Comments
 (0)