Message187008
That is indeed simpler than what I wrote, and it does work as expected. But, is it preferable to do it this way, or with Ezio's suggested method (``skip_unless_gzip = unittest.skipUnless(gzip, "gzip not available")``, and for bz2 and lzma)? I can see merits to both; mine only requires a docstring change if there's a new compression module sometime in the future, but Ezio's is simpler and shorter.
Here's another thought; would it be more useful to have a general version of this skip decorator in test.support, something along the lines of:
"""
def skipWithoutModule(name):
"""
Skip if the named module is not available.
"""
try:
module = importlib.import_module(name)
except ImportError:
module = None
return unittest.skipUnless(module,
"{} module not available".format(name))
"""
And, actually, looking through test.support to see if there was anything like this already, I found requires_bz2 and requires_lzma that already exist; should I just add a requires_gzip to test.support and use those three in test_tarfile? |
|
Date |
User |
Action |
Args |
2013-04-15 17:03:13 | zach.ware | set | recipients:
+ zach.ware, brett.cannon, pitrou, ezio.melotti |
2013-04-15 17:03:13 | zach.ware | set | messageid: <1366045393.71.0.0310990389794.issue17689@psf.upfronthosting.co.za> |
2013-04-15 17:03:13 | zach.ware | link | issue17689 messages |
2013-04-15 17:03:13 | zach.ware | create | |
|