Skip to content

Commit 71e7c31

Browse files
committed
Show actual state in engine command state assertions (#1049, #1071)
1 parent caefd4d commit 71e7c31

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

chess/engine.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ async def communicate(self, command_factory: Callable[[Self], BaseCommand[T]]) -
989989
if self.returncode.done():
990990
raise EngineTerminatedError(f"engine process dead (exit code: {self.returncode.result()})")
991991

992-
assert command.state == CommandState.NEW
992+
assert command.state == CommandState.NEW, command.state
993993

994994
if self.next_command is not None:
995995
self.next_command.result.cancel()
@@ -1253,20 +1253,20 @@ def _handle_exception(self, exc: Exception) -> None:
12531253
self.finished.set_result(None)
12541254

12551255
def set_finished(self) -> None:
1256-
assert self.state in [CommandState.ACTIVE, CommandState.CANCELLING]
1256+
assert self.state in [CommandState.ACTIVE, CommandState.CANCELLING], self.state
12571257
if not self.result.done():
12581258
self.result.set_exception(EngineError(f"engine command finished before returning result: {self!r}"))
12591259
self.finished.set_result(None)
12601260
self.state = CommandState.DONE
12611261

12621262
def _cancel(self) -> None:
12631263
if self.state != CommandState.CANCELLING and self.state != CommandState.DONE:
1264-
assert self.state == CommandState.ACTIVE
1264+
assert self.state == CommandState.ACTIVE, self.state
12651265
self.state = CommandState.CANCELLING
12661266
self.cancel()
12671267

12681268
def _start(self) -> None:
1269-
assert self.state == CommandState.NEW
1269+
assert self.state == CommandState.NEW, self.state
12701270
self.state = CommandState.ACTIVE
12711271
try:
12721272
self.check_initialized()
@@ -1275,7 +1275,7 @@ def _start(self) -> None:
12751275
self._handle_exception(err)
12761276

12771277
def _line_received(self, line: str) -> None:
1278-
assert self.state in [CommandState.ACTIVE, CommandState.CANCELLING]
1278+
assert self.state in [CommandState.ACTIVE, CommandState.CANCELLING], self.state
12791279
try:
12801280
self.line_received(line)
12811281
except EngineError as err:

0 commit comments

Comments
 (0)