diff --git a/frappe/tests/test_api.py b/frappe/tests/test_api.py index 105da8e2dc..c1cdb58cde 100644 --- a/frappe/tests/test_api.py +++ b/frappe/tests/test_api.py @@ -432,7 +432,7 @@ def after_request(*args, **kwargs): _test_REQ_HOOK["after_request"] = time() -class TestResponse(FrappeAPITestCase): +class TestAPIResponse(FrappeAPITestCase): def test_generate_pdf(self): response = self.get( "/api/method/frappe.utils.print_format.download_pdf", diff --git a/frappe/tests/test_perf.py b/frappe/tests/test_perf.py index bcb4cfa448..25732c8673 100644 --- a/frappe/tests/test_perf.py +++ b/frappe/tests/test_perf.py @@ -249,7 +249,7 @@ class TestPerformance(IntegrationTestCase): default_affinity_16 = list(range(16)) # "linear" siblings = (0,1) (2,3) ... - linear_siblings_16 = list(itertools.batched(range(16), 2)) + linear_siblings_16 = list(itertools.batched(range(16), 2, strict=True)) logical_cores = list(range(16)) expected_assignments = [*(l[0] for l in linear_siblings_16), *(l[1] for l in linear_siblings_16)] for pid, expected_core in zip(logical_cores, expected_assignments, strict=True): diff --git a/frappe/utils/__init__.py b/frappe/utils/__init__.py index 0533aaaa0d..fc86783fe7 100644 --- a/frappe/utils/__init__.py +++ b/frappe/utils/__init__.py @@ -49,8 +49,6 @@ UNSET = object() type PropertyType = property | functools.cached_property - - def get_fullname(user=None): """get the full name (first name + last name) of the user from User""" if not user: @@ -1191,44 +1189,3 @@ def create_folder(path, with_init=False): cached_property = functools.cached_property -if sys.version_info.minor < 12: - T = TypeVar("T") - - class cached_property(functools.cached_property, Generic[T]): - """ - A simpler `functools.cached_property` implementation without locks. - This isn't needed in Python 3.12+, since lock was removed in newer versions. - Hence, in those versions, it returns the `functools.cached_property` object. - - This does not prevent a possible race condition in multi-threaded usage. - The getter function could run more than once on the same instance, - with the latest run setting the cached value. If the cached property is - idempotent or otherwise not harmful to run more than once on an instance, - this is fine. If synchronization is needed, implement the necessary locking - inside the decorated getter function or around the cached property access. - """ - - def __init__(self, func: Callable[[Any], T]): - self.func = func - self.attrname = None - self.__doc__ = func.__doc__ - self.__module__ = func.__module__ - - def __set_name__(self, owner, name): - if self.attrname is None: - self.attrname = name - - elif name != self.attrname: - raise TypeError( - "Cannot assign the same cached_property to two different names " - f"({self.attrname!r} and {name!r})." - ) - - def __get__(self, instance, owner=None) -> T: - if instance is None: - return self - - value = self.func(instance) - instance.__dict__[self.attrname] = value - return value -# end: custom cached_property implementation