From b8b43a331729fd7d70f2d3765e70fd42403803b0 Mon Sep 17 00:00:00 2001 From: magianxd Date: Tue, 9 May 2017 13:03:13 +0800 Subject: [PATCH] Fix for issue 239 (#546) * Fix for issue 239 * Add unittest --- pyVmomi/SoapAdapter.py | 2 ++ tests/test_vim_session_oriented_stub.py | 13 +++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 tests/test_vim_session_oriented_stub.py diff --git a/pyVmomi/SoapAdapter.py b/pyVmomi/SoapAdapter.py index 6eaeb44..cffe865 100644 --- a/pyVmomi/SoapAdapter.py +++ b/pyVmomi/SoapAdapter.py @@ -1642,6 +1642,8 @@ class SessionOrientedStub(StubAdapterBase): if isinstance(e, self.SESSION_EXCEPTIONS): # Our session might've timed out, change our state and retry. self._SetStateUnauthenticated() + retriesLeft -= 1 + continue else: raise e return obj diff --git a/tests/test_vim_session_oriented_stub.py b/tests/test_vim_session_oriented_stub.py new file mode 100644 index 0000000..99ff359 --- /dev/null +++ b/tests/test_vim_session_oriented_stub.py @@ -0,0 +1,13 @@ +import tests + +from pyVim import connect + + +class SoapAdapterTests(tests.VCRTestBase): + def test_invoke_method_login_session_exception(self): + def login_fail(*args, **kwargs): + raise vim_session.SESSION_EXCEPTIONS[0]() + + stub = connect.SoapStubAdapter() + vim_session = connect.VimSessionOrientedStub(stub, login_fail) + self.assertRaises(SystemError, vim_session.InvokeAccessor, "mo", "info")