-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make _default.default bound method; fix #323
Previously, our JSON encoder monkey patch was to an unbound method. This resulted in throwing a misleading `TypeError` when trying to encode something non-encodable.
- Loading branch information
Showing
2 changed files
with
21 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# --------------------------------------------------------------------------- # | ||
# test_monkey.py # | ||
# # | ||
# Copyright © 2015-2021, Rajiv Bakulesh Shah, original author. # | ||
# All rights reserved. # | ||
# --------------------------------------------------------------------------- # | ||
|
||
|
||
import json | ||
|
||
from tests.base import TestCase | ||
|
||
|
||
class MonkeyKeyTests(TestCase): | ||
def test_json_encoder(self): | ||
try: | ||
json.dumps(object()) | ||
except TypeError as error: | ||
assert str(error) == \ | ||
'Object of type object is not JSON serializable' |