Message180859
| Author |
brett.cannon |
| Recipients |
Arfrever, brett.cannon, eli.bendersky, eric.snow, ezio.melotti, pitrou |
| Date |
2013年01月28日.14:51:50 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1359384711.26.0.999962935747.issue17037@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|