diff options
Diffstat (limited to 'Lib/test/test_asyncio/test_sendfile.py')
-rw-r--r-- | Lib/test/test_asyncio/test_sendfile.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Lib/test/test_asyncio/test_sendfile.py b/Lib/test/test_asyncio/test_sendfile.py index 01c6986..0a5466a 100644 --- a/Lib/test/test_asyncio/test_sendfile.py +++ b/Lib/test/test_asyncio/test_sendfile.py @@ -36,25 +36,29 @@ class MySendfileProto(asyncio.Protocol): self.data = bytearray() self.close_after = close_after + def _assert_state(self, *expected): + if self.state not in expected: + raise AssertionError(f'state: {self.state!r}, expected: {expected!r}') + def connection_made(self, transport): self.transport = transport - assert self.state == 'INITIAL', self.state + self._assert_state('INITIAL') self.state = 'CONNECTED' if self.connected: self.connected.set_result(None) def eof_received(self): - assert self.state == 'CONNECTED', self.state + self._assert_state('CONNECTED') self.state = 'EOF' def connection_lost(self, exc): - assert self.state in ('CONNECTED', 'EOF'), self.state + self._assert_state('CONNECTED', 'EOF') self.state = 'CLOSED' if self.done: self.done.set_result(None) def data_received(self, data): - assert self.state == 'CONNECTED', self.state + self._assert_state('CONNECTED') self.nbytes += len(data) self.data.extend(data) super().data_received(data) |