diff --git a/tests/test_exec_control.py b/tests/test_exec_control.py index 70e28aec..5dedb38c 100644 --- a/tests/test_exec_control.py +++ b/tests/test_exec_control.py @@ -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) diff --git a/wa/utils/exec_control.py b/wa/utils/exec_control.py index 29261937..04d84e10 100644 --- a/wa/utils/exec_control.py +++ b/wa/utils/exec_control.py @@ -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: