Skip to content

Commit 1466b5e

Browse files
committed
Test: Rename field
1 parent 5a1fe50 commit 1466b5e

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

tests/nexus/test_handler.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,15 +307,24 @@ async def non_serializable_output(
307307

308308
@dataclass
309309
class Failure:
310+
"""A Nexus Failure object, with details parsed into an exception.
311+
312+
https://github.com/nexus-rpc/api/blob/main/SPEC.md#failure
313+
"""
314+
310315
message: str = ""
311316
metadata: Optional[dict[str, str]] = None
312317
details: Optional[dict[str, Any]] = None
313318

314-
exception: Optional[BaseException] = dataclasses.field(init=False, default=None)
319+
exception_from_details: Optional[BaseException] = dataclasses.field(
320+
init=False, default=None
321+
)
315322

316323
def __post_init__(self) -> None:
317324
if self.metadata and (error_type := self.metadata.get("type")):
318-
self.exception = self._instantiate_exception(error_type, self.details)
325+
self.exception_from_details = self._instantiate_exception(
326+
error_type, self.details
327+
)
319328

320329
def _instantiate_exception(
321330
self, error_type: str, details: Optional[dict[str, Any]]
@@ -420,9 +429,9 @@ def check_response(
420429
else:
421430
assert cls.expected.retryable_header is None
422431

423-
if failure.exception:
424-
assert isinstance(failure.exception, ApplicationError)
425-
assert failure.exception.non_retryable == (
432+
if failure.exception_from_details:
433+
assert isinstance(failure.exception_from_details, ApplicationError)
434+
assert failure.exception_from_details.non_retryable == (
426435
not cls.expected.retryable_exception
427436
)
428437
else:
@@ -607,7 +616,7 @@ def check_response(
607616
) -> None:
608617
super().check_response(response, with_service_definition)
609618
failure = Failure(**response.json())
610-
err = failure.exception
619+
err = failure.exception_from_details
611620
assert isinstance(err, ApplicationError)
612621
assert err.non_retryable
613622
assert err.type == "TestFailureType"

0 commit comments

Comments
 (0)