From a57d5d9bbc27a7c3f18e14f68cfc74477b50eda0 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Fri, 3 May 2019 13:03:14 +0300 Subject: [PATCH] Made bytes and str return types no longer mutually exclusive in lazy(). They are no longer special cased. --- django/utils/functional.py | 7 ------- tests/utils_tests/test_functional.py | 4 +--- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/django/utils/functional.py b/django/utils/functional.py index be5fac23ad..66d88d9b59 100644 --- a/django/utils/functional.py +++ b/django/utils/functional.py @@ -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): diff --git a/tests/utils_tests/test_functional.py b/tests/utils_tests/test_functional.py index cc4409d893..9a5cbfe068 100644 --- a/tests/utils_tests/test_functional.py +++ b/tests/utils_tests/test_functional.py @@ -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)()