forked from psf/requests
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1466ad7
commit 5ff9fb7
Showing
6 changed files
with
68 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import pytest | ||
import simplejson | ||
import json | ||
|
||
from requests import get, JSONDecodeError | ||
|
||
success_url = "https://httpbin.org/get" | ||
failure_url = "https://google.com" | ||
|
||
|
||
def test_json_decode_success(): | ||
assert isinstance(get(success_url).json(), dict) | ||
|
||
|
||
def test_json_decode_failure_normal_catch(): | ||
with pytest.raises(json.JSONDecodeError): | ||
get(failure_url).json() | ||
|
||
|
||
def test_json_decode_failure_simplejson_catch(): | ||
with pytest.raises(simplejson.JSONDecodeError): | ||
get(failure_url).json() |