This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author zach.ware
Recipients brett.cannon, ezio.melotti, pitrou, zach.ware
Date 2013-04-15.17:03:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1366045393.71.0.0310990389794.issue17689@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2013-04-15 17:03:13zach.waresetrecipients: + zach.ware, brett.cannon, pitrou, ezio.melotti
2013-04-15 17:03:13zach.waresetmessageid: <1366045393.71.0.0310990389794.issue17689@psf.upfronthosting.co.za>
2013-04-15 17:03:13zach.warelinkissue17689 messages
2013-04-15 17:03:13zach.warecreate