File tree Expand file tree Collapse file tree 3 files changed +9
-9
lines changed
Expand file tree Collapse file tree 3 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -16,9 +16,8 @@ def class_decorator(cls):
1616 if not private_methods :
1717 continue
1818
19- elif attr_name .startswith ("_" ):
20- if not protected_methods :
21- continue
19+ elif attr_name .startswith ("_" ) and not protected_methods :
20+ continue
2221
2322 # Replace the original callable with the decorated version
2423 setattr (cls , attr_name , decorator (attr_value ))
Original file line number Diff line number Diff line change 66
77from common .tracing import trace_function
88from common .utils import apply_decorator_to_methods
9+
910from ._gateway_interfaces import BookEventGatewayInterface , BookRepositoryInterface
1011from ._models import BookModel
1112from ._tasks import book_cpu_intensive_task
Original file line number Diff line number Diff line change 88@pytest .mark .parametrize (
99 "apply_to_protected_methods" ,
1010 [
11- True ,
12- False ,
11+ pytest . param ( True , id = "protected_methods" ) ,
12+ pytest . param ( False , id = "no_protected_methods" ) ,
1313 ],
1414)
1515@pytest .mark .parametrize (
1616 "apply_to_private_methods" ,
1717 [
18- True ,
19- False ,
18+ pytest . param ( True , id = "private_methods" ) ,
19+ pytest . param ( False , id = "no_private_methods" ) ,
2020 ],
2121)
2222async def test_class_decorator (
@@ -61,7 +61,7 @@ async def __get_aprivate(self):
6161 c = MyClass ()
6262 assert c .get_public () == 20
6363 assert c ._get_protected () == 20 if apply_to_protected_methods else 10
64- assert c ._MyClass__get_private () == 20 if apply_to_private_methods else 10
64+ assert c ._MyClass__get_private () == 20 if apply_to_private_methods else 10 # type: ignore
6565 assert await c .get_apublic () == 20
6666 assert await c ._get_aprotected () == 20 if apply_to_protected_methods else 10
67- assert await c ._MyClass__get_aprivate () == 20 if apply_to_private_methods else 10
67+ assert await c ._MyClass__get_aprivate () == 20 if apply_to_private_methods else 10 # type: ignore
You can’t perform that action at this time.
0 commit comments