check for a certain Python version
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Tue Dec 20 14:53:57 EST 2011
On Tue, 20 Dec 2011 14:33:37 +0100, Ulrich Eckhardt wrote:
> Hi!
>
> I'd like to give my users a meaningful error message when they are using
> obsolete Python versions. Is there some kind of best practice or recipe
> for that? Specifically, the case is a bunch of unittests that use
> features new to Python 2.7.
if sys.version < "2.7": ...
Or test for features and either provide your own, or disable
functionality not available:
class MyTest:
try:
@unittest.FancyFeature
def testFancy(self):
self.assertFancy(self, ...)
except AttributeError:
pass
--
Steven
More information about the Python-list
mailing list