Get func.__class__.__name__ if no attribute __name__
In call_until_true, if func is wrapped with functools.partial,
getattr(func, '__name__') will get "AttributeError:
'functools.partial' object has no attribute '__name__'"
Now call_until_true supports args and kwargs that are passed
to func, so functools.partial is no longer needed, but it's
better for call_until_true to get func.__class__.__name__
if func has not attritube __name__.
Change-Id: Icc734e44af925655a31e7dcac04620352093cbeb
Closes-Bug: #1744210
diff --git a/tempest/lib/common/utils/test_utils.py b/tempest/lib/common/utils/test_utils.py
index c2e93ee..2a9f3a9 100644
--- a/tempest/lib/common/utils/test_utils.py
+++ b/tempest/lib/common/utils/test_utils.py
@@ -102,13 +102,13 @@
now = time.time()
begin_time = now
timeout = now + duration
+ func_name = getattr(func, '__name__', getattr(func.__class__, '__name__'))
while now < timeout:
if func(*args, **kwargs):
LOG.debug("Call %s returns true in %f seconds",
- getattr(func, '__name__'), time.time() - begin_time)
+ func_name, time.time() - begin_time)
return True
time.sleep(sleep_for)
now = time.time()
- LOG.debug("Call %s returns false in %f seconds",
- getattr(func, '__name__'), duration)
+ LOG.debug("Call %s returns false in %f seconds", func_name, duration)
return False