Skip to content

Commit 84a74d8

Browse files
committed
chore: save mismatches before exiting the server
Signed-off-by: JP-Ellis <[email protected]>
1 parent 5a9c628 commit 84a74d8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/pact/pact.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,7 @@ def __init__( # noqa: PLR0913
640640
self._handle: None | pact_ffi.PactServerHandle = None
641641
self._raises = raises
642642
self._verbose = verbose
643+
self._mismatches: list[Mismatch] | None = None
643644

644645
@property
645646
def port(self) -> int | None:
@@ -702,6 +703,9 @@ def mismatches(self) -> list[Mismatch]:
702703
RuntimeError:
703704
If the server is not running.
704705
"""
706+
if self._mismatches is not None:
707+
return self._mismatches
708+
705709
if not self._handle:
706710
msg = "The server is not running."
707711
raise RuntimeError(msg)
@@ -796,6 +800,7 @@ def __exit__(
796800
logger.error(msg)
797801
if self._raises:
798802
raise MismatchesError(*self.mismatches)
803+
self._mismatches = self.mismatches
799804
self._handle = None
800805

801806
def __truediv__(self, other: str | object) -> URL:

0 commit comments

Comments
 (0)