mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Made bytes and str return types no longer mutually exclusive in lazy().
They are no longer special cased.
This commit is contained in:
parent
459f30f73e
commit
a57d5d9bbc
@ -119,13 +119,6 @@ def lazy(func, *resultclasses):
|
||||
continue
|
||||
meth = cls.__promise__(method_name)
|
||||
setattr(cls, method_name, meth)
|
||||
cls._delegate_bytes = bytes in resultclasses
|
||||
cls._delegate_text = str in resultclasses
|
||||
if cls._delegate_bytes and cls._delegate_text:
|
||||
raise ValueError(
|
||||
"Cannot call lazy() with both bytes and text return types."
|
||||
)
|
||||
|
||||
|
||||
@classmethod
|
||||
def __promise__(cls, method_name):
|
||||
|
@ -234,9 +234,7 @@ class FunctionalTests(SimpleTestCase):
|
||||
|
||||
def test_lazy_bytes_and_str_result_classes(self):
|
||||
lazy_obj = lazy(lambda: "test", str, bytes)
|
||||
msg = "Cannot call lazy() with both bytes and text return types."
|
||||
with self.assertRaisesMessage(ValueError, msg):
|
||||
lazy_obj()
|
||||
self.assertEqual(str(lazy_obj()), "test")
|
||||
|
||||
def test_lazy_str_cast_mixed_result_types(self):
|
||||
lazy_value = lazy(lambda: [1], str, list)()
|
||||
|
Loading…
Reference in New Issue
Block a user