diff --git a/jsonschema/tests/test_validators.py b/jsonschema/tests/test_validators.py index 0bc60deaf..8d876a7b0 100644 --- a/jsonschema/tests/test_validators.py +++ b/jsonschema/tests/test_validators.py @@ -2323,5 +2323,8 @@ class _ReallyFakeJSONResponse: _response = attr.ib() + def raise_for_status(self): + return None + def json(self): return json.loads(self._response) diff --git a/jsonschema/validators.py b/jsonschema/validators.py index d370dc5b6..09e68aa8a 100644 --- a/jsonschema/validators.py +++ b/jsonschema/validators.py @@ -1013,7 +1013,9 @@ def resolve_remote(self, uri): elif scheme in ["http", "https"] and requests: # Requests has support for detecting the correct encoding of # json over http - result = requests.get(uri).json() + response = requests.get(uri) + response.raise_for_status() + result = response.json() else: # Otherwise, pass off to urllib and assume utf-8 with urlopen(uri) as url: