-
Notifications
You must be signed in to change notification settings - Fork 117
Closed
Description
I've got a test method decorated with a @run_before() method, like (for example):
@rfm.run_before('run')
def no_run(self):
""" Turn the run phase into a no-op to help debugging. """
with open(os.path.join(self.stagedir, 'noop.sh'), 'w') as noop:
noop.write('#!/bin/bash\necho "noop $@"\n')
self.executable = "./noop.sh"
which really I want to pull out into a separate library so I can use it on various classes (it's more complex than the method here so it makes more sense!).
I can't figure out how to monkey-patch this in though - the run_before decorator seems to make a difference. Ideally I'd do something like:
@set_no_run
@rfm.simple_test
class MyTest(rfm.RegressionTest):
<snip>
I tried this:
def set_no_run(cls):
def no_run(self):
""" Turn the run phase into a no-op. """
with open(os.path.join(self.stagedir, 'noop.sh'), 'w') as noop:
noop.write('#!/bin/bash\necho "noop $@"\n')
self.executable = "./noop.sh"
cls.no_run = no_run
cls.no_run = rfm.run_before('run')(cls.no_run)
return cls
but (unsurprisingly?) that doesn't work (as in, doesn't change the executable).
Maybe I'm missing something about the way binding works in Py3 here but I'd appreciate any suggestions for how to do something like this, even if it's via another route.