diff --git a/oec/tn3270.py b/oec/tn3270.py index d6f13bb..66683ba 100644 --- a/oec/tn3270.py +++ b/oec/tn3270.py @@ -84,7 +84,7 @@ class TN3270Session(Session): try: if not self.emulator.update(timeout=0): return False - except EOFError: + except (EOFError, ConnectionResetError): self._disconnect_host() raise SessionDisconnectedError diff --git a/tests/test_tn3270.py b/tests/test_tn3270.py index 66e91e6..873fc75 100644 --- a/tests/test_tn3270.py +++ b/tests/test_tn3270.py @@ -75,6 +75,16 @@ class SessionHandleHostTestCase(unittest.TestCase): self.telnet.close.assert_called() + def test_connection_reset(self): + # Arrange + self.session.emulator.update = Mock(side_effect=ConnectionResetError) + + # Act and assert + with self.assertRaises(SessionDisconnectedError): + self.session.handle_host() + + self.telnet.close.assert_called() + def test_keyboard_locked(self): # Arrange self.session.emulator.update = Mock(return_value=True)