@@ -47,10 +47,14 @@ def __init__(self, sift_client: SiftClient):
4747 self ._low_level_client = TestResultsLowLevelClient (grpc_client = self .client .grpc_client )
4848 self ._upload_client = UploadLowLevelClient (rest_client = self .client .rest_client )
4949
50- @staticmethod
51- def _associate_log_file (instance , log_file : str | Path | None ):
52- # Mirror BaseType._apply_client_to_instance: bypass frozen by writing to
53- # __dict__ directly.
50+ def _finalize (self , instance , log_file : str | Path | None ):
51+ """Attach the client and stamp the log file on a returned entity.
52+
53+ Bypasses the frozen-model guard the same way `_apply_client_to_instance`
54+ does. Read paths skip this and call `_apply_client_to_instance` directly
55+ so fetched entities don't carry a log file they didn't originate from.
56+ """
57+ self ._apply_client_to_instance (instance )
5458 instance .__dict__ ["_log_file" ] = log_file
5559 return instance
5660
@@ -93,7 +97,7 @@ async def create(
9397 test_report = test_report ,
9498 log_file = log_file ,
9599 )
96- return self ._associate_log_file ( self . _apply_client_to_instance ( created_report ) , log_file )
100+ return self ._finalize ( created_report , log_file )
97101
98102 async def get (self , * , test_report_id : str ) -> TestReport :
99103 """Get a TestReport.
@@ -269,9 +273,7 @@ async def update(
269273 updated_test_report = await self ._low_level_client .update_test_report (
270274 update , log_file = log_file , existing = existing
271275 )
272- return self ._associate_log_file (
273- self ._apply_client_to_instance (updated_test_report ), log_file
274- )
276+ return self ._finalize (updated_test_report , log_file )
275277
276278 async def archive (self , * , test_report : str | TestReport ) -> TestReport :
277279 """Archive a test report.
@@ -319,7 +321,7 @@ async def create_step(
319321 test_step_result = await self ._low_level_client .create_test_step (
320322 test_step , log_file = log_file
321323 )
322- return self ._associate_log_file ( self . _apply_client_to_instance ( test_step_result ) , log_file )
324+ return self ._finalize ( test_step_result , log_file )
323325
324326 async def list_steps (
325327 self ,
@@ -450,7 +452,7 @@ async def update_step(
450452 updated_test_step = await self ._low_level_client .update_test_step (
451453 update , log_file = log_file , existing = existing
452454 )
453- return self ._associate_log_file ( self . _apply_client_to_instance ( updated_test_step ) , log_file )
455+ return self ._finalize ( updated_test_step , log_file )
454456
455457 async def delete_step (self , * , test_step : str | TestStep ) -> None :
456458 """Delete a test step.
@@ -484,9 +486,7 @@ async def create_measurement(
484486 test_measurement_result = await self ._low_level_client .create_test_measurement (
485487 test_measurement , log_file = log_file
486488 )
487- measurement = self ._associate_log_file (
488- self ._apply_client_to_instance (test_measurement_result ), log_file
489- )
489+ measurement = self ._finalize (test_measurement_result , log_file )
490490 if update_step and log_file is None :
491491 step = await self .get_step (test_step = test_measurement_result .test_step_id )
492492 if step .status == TestStatus .PASSED and not measurement .passed :
@@ -623,9 +623,7 @@ async def update_measurement(
623623 updated_test_measurement = await self ._low_level_client .update_test_measurement (
624624 update , log_file = log_file , existing = test_measurement
625625 )
626- updated_test_measurement = self ._associate_log_file (
627- self ._apply_client_to_instance (updated_test_measurement ), log_file
628- )
626+ updated_test_measurement = self ._finalize (updated_test_measurement , log_file )
629627 if update_step and log_file is None and update .passed is not None and not update .passed :
630628 step = await self .get_step (test_step = updated_test_measurement .test_step_id )
631629 if step .status == TestStatus .PASSED :
0 commit comments