[TIP] unittest version info
Julien Jehannet
julien at smaf.org
Thu Sep 9 04:07:48 PDT 2010
Hello TIP,
In order to move old testlib assertion methods to new (standard)
unittest2 incarnations, I would retrieve unittest info installed
in my system.
But I can't find any attribute to rely on. And __version__ was quite
confusing at the moment.
% python2.5 -c 'import unittest; print unittest.__version__'
1.63
% PYTHONPATH=unittest2 python2.5 -c 'import unittest2 as unittest; print unittest.__version__'
0.6.0 alpha (plugins branch)
% python3.1 -c 'import unittest; unittest.__version__'
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute '__version__'
Is there a standard way to detect unittest flavour ?
If not yet, may I suggest to have similar convention that the sys module¹ ?
- a __version__ string module attribute (which should be >2.X IMO)
- but also a __version_info__ tuple containing the separated fields
__version_info__ = tuple([int(num) for num in __version__.split('.')])
The only interest here is to ease version comparaison afterwards.
Note: maybe it can be worth to follow PEP-0386² for string version
convention (i.e. no space for example)
Best Regards,
¹ http://docs.python.org/library/sys.html#sys.version_info
² http://www.python.org/dev/peps/pep-0386/
--
N e h u m a n u s c r e d e
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20100909/7299dfc8/attachment.pgp>
More information about the testing-in-python
mailing list