Strange behaviour when redefining hook and assigning it to a different stage
See original GitHub issueThe following code leads to the strange behaviour that the second check_x()
overrides the first (as expected) but the hooks are not overridden, leaving the second check_x()
executing as a post-init hook. We should either disable redefinitions of the same hook in the same class or have the second definition and hook override completely the first one.
@simple_test
class my_test(RegressionTest):
x = variable(int, value=10)
@run_after('init')
def check_x(self):
'''Test will not be listed or run if filtered here'''
self.skip_if(self.x < 3, 'x is lower than 3')
@run_after('setup')
def check_x(self):
'''Test will be skipped during runtime'''
self.skip_if(self.x < 5, 'x is lower than 5')
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
TIP 57 Trauma-Informed Care in Behavioral Health Services
Strategy #4: Assign a Key Staff Member To Facilitate Change . ... ment principles that guide clinicians, other behavioral health workers, and administrators ......
Read more >Lorber. “Night to his Day”: The Social Construction of Gender
In the construction of ascribed social statuses, physiological differences such as sex, stage of development, color of skin, and size are crude markers....
Read more >Teaching To Transgress - University Blog Service
really belonging, taught me the difference between education as the practice of freedom and education that merely strives to reinforce domination. The rare...
Read more >The Secrets to Successful Strategy Execution
The new chief executive chose to focus less on cost control and more on profitable growth by redefining the divisions to focus on...
Read more >The Norton Sampler 9e - Parma City School District
W. W. Norton & Company, Inc., 500 Fifth Avenue, New York, NY 10110 ... though you were a reporter on assignment or a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
What actually happens is the following:
check_x
is first added to the hook registry as apost_init
hook https://github.com/eth-cscs/reframe/blob/12b48588980e411fbfe17f32b864fd6eaf7450b5/reframe/core/hooks.py#L154check_x
is added to the hook registry as apost_setup
hook, but because it’s wrapped as aHook
instance and has the same name as thecheck_x
on step 1, it’s not taken into account, since a hook with the same name is already in the registrypost_init
one with thecheck_x
name, but the RegressionTest object attribute namedcheck_x
refers to the secondcheck_x
function that replaced the first.check_x
executed as apost_init
hookI suggest overriding completely a hook with the same name if redefined as another stage hook.
Nice find and intricate bug! Thanks @teojgo for investigating!
Yes, I think it makes sense and it is compatible with what happens when a hook is redefined in a subclass.