mirror of
https://github.com/lowobservable/oec.git
synced 2026-02-27 09:09:56 +00:00
Disconnect session on ConnectionResetError
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user