<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    On 09/09/2010 12:07, Julien Jehannet wrote:
    <blockquote cite="mid:20100909110745.GA25366@crater.logilab.fr"
      type="cite">
      <pre wrap="">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 "&lt;string&gt;", line 1, in &lt;module&gt;
        AttributeError: 'module' object has no attribute '__version__'

Is there a standard way to detect unittest flavour ?
</pre>
    </blockquote>
    <br>
    The __version__ number in unittest is something I haven't
    maintained, so it is my fault that it doesn't make sense.<br>
    <br>
    *However*, there is little point in it containing anything other
    than the Python version number as unittest APIs change at least
    slightly with every major release.<br>
    <br>
    So... the simple rule is that if you have unittest then use the
    Python version, if you have unittest2 then you can trust its
    __version__ attribute. You can tell if you have unittest2 because
    there will be 'unittest2' somewhere in __file__ for the unittest2
    modules. (And also because you imported it...)<br>
    <br>
    Michael Foord<br>
    <br>
    <br>
    <blockquote cite="mid:20100909110745.GA25366@crater.logilab.fr"
      type="cite">
      <pre wrap="">If not yet, may I suggest to have similar convention that the sys module&sup1; ?
- a __version__ string module attribute (which should be &gt;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&sup2; for string version
convention (i.e. no space for example)


Best Regards,

&sup1; <a class="moz-txt-link-freetext" href="http://docs.python.org/library/sys.html#sys.version_info">http://docs.python.org/library/sys.html#sys.version_info</a>
&sup2; <a class="moz-txt-link-freetext" href="http://www.python.org/dev/peps/pep-0386/">http://www.python.org/dev/peps/pep-0386/</a>
</pre>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
testing-in-python mailing list
<a class="moz-txt-link-abbreviated" href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a>
<a class="moz-txt-link-freetext" href="http://lists.idyll.org/listinfo/testing-in-python">http://lists.idyll.org/listinfo/testing-in-python</a>
</pre>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
<a class="moz-txt-link-freetext" href="http://www.ironpythoninaction.com/">http://www.ironpythoninaction.com/</a>
<a class="moz-txt-link-freetext" href="http://www.voidspace.org.uk/blog">http://www.voidspace.org.uk/blog</a>

READ CAREFULLY. By accepting and reading this email you agree, on behalf of your employer, to release me from all obligations and waivers arising from any and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and acceptable use policies (&#8221;BOGUS AGREEMENTS&#8221;) that I have entered into with your employer, its partners, licensors, agents and assigns, in perpetuity, without prejudice to my ongoing rights and privileges. You further represent that you have the authority to release me from any BOGUS AGREEMENTS on behalf of your employer.

</pre>
  </body>
</html>