def test_on_leave_valid_session_deferred(self):
            session = MockApplicationSession()
            exception = RuntimeError("such challenge")
            session.onLeave = async_exception_raiser(exception)
            # we have to get to an established connection first...
            session.onMessage(create_mock_welcome())
            self.assertTrue(session._session_id is not None)

            # okay we have a session ("because ._session_id is not None")
            msg = message.Goodbye()
            session.onMessage(msg)

            self.assertEqual(1, len(session.errors))
            self.assertEqual(exception, session.errors[0][0])
cover when onLeave called after we have a valid session
dataset/ETHPy150Open crossbario/autobahn-python/autobahn/wamp/test/test_user_handler_errors.py/TestSessionCallbacks.test_on_leave_valid_session_deferred