summaryrefslogtreecommitdiffstats
path: root/ipatests
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2016-04-29 14:10:28 +0200
committerMartin Basti <mbasti@redhat.com>2016-05-05 16:42:46 +0200
commit6406c7a5935e9fb9cd41af49f67d6200021b3574 (patch)
treed6b2a4ff631f985b39530a69c51c3c80b7d420de /ipatests
parentf753ad322dfdd81907a309827bddfcb1e47917a7 (diff)
downloadfreeipa-6406c7a5935e9fb9cd41af49f67d6200021b3574.tar.gz
freeipa-6406c7a5935e9fb9cd41af49f67d6200021b3574.tar.xz
freeipa-6406c7a5935e9fb9cd41af49f67d6200021b3574.zip
xmlrpc_test: Rename exception instance before working with it
Python 3 unsets the exception variable at the end of an "except" block to prevent reference cycles and speed up garbage collection. Store the exception under a different name in order to use it later. Part of the work for https://fedorahosted.org/freeipa/ticket/4985 Reviewed-By: Martin Basti <mbasti@redhat.com> Reviewed-By: Petr Spacek <pspacek@redhat.com>
Diffstat (limited to 'ipatests')
-rw-r--r--ipatests/test_xmlrpc/xmlrpc_test.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/ipatests/test_xmlrpc/xmlrpc_test.py b/ipatests/test_xmlrpc/xmlrpc_test.py
index 330889341..4052ab918 100644
--- a/ipatests/test_xmlrpc/xmlrpc_test.py
+++ b/ipatests/test_xmlrpc/xmlrpc_test.py
@@ -330,14 +330,15 @@ class Declarative(XMLRPC_test):
try:
output = api.Command[cmd](*args, **options)
except Exception as e:
- pass
+ exception = e
else:
raise AssertionError(
EXPECTED % (cmd, name, args, options, output)
)
- if not isinstance(e, klass):
+ if not isinstance(exception, klass):
raise AssertionError(
- UNEXPECTED % (cmd, name, args, options, e.__class__.__name__, e)
+ UNEXPECTED % (cmd, name, args, options,
+ exception.__class__.__name__, exception)
)
# FIXME: the XML-RPC transport doesn't allow us to return structured
# information through the exception, so we can't test the kw on the
@@ -345,21 +346,21 @@ class Declarative(XMLRPC_test):
# transport, the exception is a free-form data structure (dict).
# For now just compare the strings
# pylint: disable=no-member
- assert_deepequal(expected.strerror, e.strerror)
+ assert_deepequal(expected.strerror, exception.strerror)
# pylint: enable=no-member
def check_callable(self, nice, cmd, args, options, expected):
name = expected.__class__.__name__
output = dict()
- e = None
+ exception = None
try:
output = api.Command[cmd](*args, **options)
except Exception as e:
- pass
- if not expected(e, output):
+ exception = e
+ if not expected(exception, output):
raise AssertionError(
UNEXPECTED % (cmd, name, args, options,
- type(e).__name__, e)
+ type(exception).__name__, exception)
)
def check_output(self, nice, cmd, args, options, expected, extra_check):