True, the current idiom needs to still be used in those cases, although we could introduce another method to help with this situation as well:
# Could also be named use_accelerator to be less hostile-sounding.
def requires_accelerator(self, cls):
if self.accelerated_module is None:
raise SkipTest # With proper message
else:
setattr(cls, self.module_name, self.accelerated_module)
return cls
Then the idiom becomes:
@pep399_tests.requires_accelerator
class AcceleratorSpecificTests(unittest.TestCase): pass
This then extends out to also the current idiom if you don't want to have any "magical" classes:
@pep399_tests.requires_accelerator
class AcceleratedExampleTests(unittest.TestCase): pass
# Can add another decorator for this if desired.
class PyExampleTests(unittest.TestCase):
module = pep399_tests.py_module
This also has the benefit of extracting out the module attribute name to minimize messing even that up.