mirror of
https://github.com/django/django.git
synced 2025-04-10 08:19:39 +00:00
Remove unused util method
This commit is contained in:
parent
499d040b0b
commit
fef3662e5d
@ -1,7 +1,6 @@
|
||||
import inspect
|
||||
import json
|
||||
import time
|
||||
from collections import deque
|
||||
from functools import wraps
|
||||
from traceback import format_exception
|
||||
|
||||
@ -18,18 +17,6 @@ def is_global_function(func):
|
||||
return True
|
||||
|
||||
|
||||
def is_json_serializable(obj):
|
||||
"""
|
||||
Determine, as efficiently as possible, whether an object is JSON-serializable.
|
||||
"""
|
||||
try:
|
||||
# HACK: JSON-encode an object, without loading it all into memory
|
||||
deque(json.JSONEncoder().iterencode(obj), maxlen=0)
|
||||
return True
|
||||
except (TypeError, OverflowError):
|
||||
return False
|
||||
|
||||
|
||||
def json_normalize(obj):
|
||||
"""
|
||||
Round-trip encode object as JSON to normalize types.
|
||||
|
@ -48,22 +48,6 @@ class IsGlobalFunctionTestCase(SimpleTestCase):
|
||||
self.assertFalse(is_global_function_fixture.inner_func_is_global_function)
|
||||
|
||||
|
||||
class IsJSONSerializableTestCase(SimpleTestCase):
|
||||
def test_serializable(self):
|
||||
for example in [123, 12.3, "123", {"123": 456}, [], None]:
|
||||
with self.subTest(example):
|
||||
self.assertTrue(utils.is_json_serializable(example))
|
||||
|
||||
def test_not_serializable(self):
|
||||
for example in [
|
||||
self,
|
||||
any,
|
||||
datetime.datetime.now(),
|
||||
]:
|
||||
with self.subTest(example):
|
||||
self.assertFalse(utils.is_json_serializable(example))
|
||||
|
||||
|
||||
class JSONNormalizeTestCase(SimpleTestCase):
|
||||
def test_round_trip(self):
|
||||
self.assertEqual(utils.json_normalize({}), {})
|
||||
|
Loading…
x
Reference in New Issue
Block a user