[Python Wpg] Testing for Python version
Jason Hildebrand
jason at peaceworks.ca
Tue Oct 16 12:55:48 EDT 2007
Hi Syd,
Why not simply check for the feature(s) you need? I have seen lots of python code which takes this approach. For example:
def _test(verbose)
if hasattr(doctest, 'ELLIPSIS'):
doctest.testmod(verbose=verbose,optionflags=doctest.ELLIPSIS)
else:
doctest.testmod(verbose=verbose)
peace,
Jason
--
Jason Hildebrand
PeaceWorks Computer Consulting
#2 - 396 Assiniboine Ave, Winnipeg
204 480 0314 --or-- 519 725 7875, ext 620.
----- "Sydney Weidman" <syd at plug.ca> wrote:
> Hi, all!
>
> I'm trying to create doctests that will work on multiple platforms,
> each
> with different versions of Python. OSX includes version 2.3.0, which
> doesn't have doctest.ELLIPSIS constant available, so I need to skip
> using that constant on OSX. It seems as if the idiom for testing
> Python
> version is sys.version_info[:3] >= (2,4,0):
>
> import sys
> import doctest
>
> def _test(verbose)
> if sys.version_info[:3] >= (2,4,0):
> doctest.testmod(verbose=verbose,optionflags=doctest.ELLIPSIS)
> else:
> doctest.testmod(verbose=verbose)
>
> Does this seem like the "right" way to test python version?
>
> I can't seem to find any definitive documentation about how to do
> this.
>
> - syd
>
>
> _______________________________________________
> Winnipeg mailing list
> Winnipeg at python.org
> http://mail.python.org/mailman/listinfo/winnipeg
More information about the Winnipeg
mailing list