mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-18 12:06:08 +00:00
ExecControl: Fixes bug with inheritance
Previously there was no differentiation between the same method at different inheritance levels, therefore using the once_per_instance_decorator with super call would prevent the super call from executing as they were considered the same instance.
This commit is contained in:
parent
3a376525cd
commit
91c49d9e95
@ -46,12 +46,42 @@ class SubClass(TestClass):
|
||||
def __init__(self):
|
||||
super(SubClass, self).__init__()
|
||||
|
||||
@once
|
||||
def initilize_once(self):
|
||||
super(SubClass, self).initilize_once()
|
||||
self.count += 1
|
||||
|
||||
@once_per_class
|
||||
def initilize_once_per_class(self):
|
||||
super(SubClass, self).initilize_once_per_class()
|
||||
self.count += 1
|
||||
|
||||
@once_per_instance
|
||||
def initilize_once_per_instance(self):
|
||||
super(SubClass, self).initilize_once_per_instance()
|
||||
self.count += 1
|
||||
|
||||
|
||||
class SubSubClass(SubClass):
|
||||
|
||||
def __init__(self):
|
||||
super(SubSubClass, self).__init__()
|
||||
|
||||
@once
|
||||
def initilize_once(self):
|
||||
super(SubSubClass, self).initilize_once()
|
||||
self.count += 1
|
||||
|
||||
@once_per_class
|
||||
def initilize_once_per_class(self):
|
||||
super(SubSubClass, self).initilize_once_per_class()
|
||||
self.count += 1
|
||||
|
||||
@once_per_instance
|
||||
def initilize_once_per_instance(self):
|
||||
super(SubSubClass, self).initilize_once_per_instance()
|
||||
self.count += 1
|
||||
|
||||
|
||||
class AnotherClass(object):
|
||||
|
||||
@ -262,8 +292,8 @@ class OncePerInstanceEnvironmentTest(TestCase):
|
||||
|
||||
sc.initilize_once_per_instance()
|
||||
sc.initilize_once_per_instance()
|
||||
assert_equal(sc.count, 1)
|
||||
assert_equal(sc.count, 2)
|
||||
|
||||
ss.initilize_once_per_instance()
|
||||
ss.initilize_once_per_instance()
|
||||
assert_equal(ss.count, 1)
|
||||
assert_equal(ss.count, 3)
|
||||
|
@ -59,7 +59,7 @@ def once_per_instance(method):
|
||||
def wrapper(*args, **kwargs):
|
||||
if __active_environment is None:
|
||||
activate_environment('default')
|
||||
func_id = repr(args[0])
|
||||
func_id = repr(method.__hash__()) + repr(args[0])
|
||||
if func_id in __environments[__active_environment]:
|
||||
return
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user