

def test_on_leave_valid_session(self):
    '\n            cover when onLeave called after we have a valid session\n            '
    session = MockApplicationSession()
    exception = RuntimeError('such challenge')
    session.onLeave = exception_raiser(exception)
    session.onMessage(create_mock_welcome())
    self.assertTrue((session._session_id is not None))
    msg = message.Goodbye()
    session.onMessage(msg)
    self.assertEqual(1, len(session.errors))
    self.assertEqual(exception, session.errors[0][0])

dataset/ETHPy150Open crossbario/autobahn-python/autobahn/wamp/test/test_user_handler_errors.py TestSessionCallbacks.test_on_leave_valid_session/original