Wednesday, June 12, 2013

nose.tools includes unittest assert methods

I came across this gem in the nose documentation today:
The nose.tools module provides a number of testing aids that you may find useful, including ... all of the same assertX methods found in unittest.TestCase (only spelled in PEP 8 fashion, so assert_equal rather than assertEqual).
Hello nose.tools.assert_almost_equal() goodbye float comparison frustration!

Managing Python Virtualenvs on Windows

I have been using virtualenvwrapper (VEW):

http://virtualenvwrapper.readthedocs.org/

for some time on my Linux desktop.  I don't do a whole lot of Windows development, but when I do, I miss VEW.  Looks like there are some solutions for Windows as well:

Monday, June 10, 2013

"cannot import name MAXREPEAT" after Python 2.7.5 Upgrade

I recently upgraded to Python 2.7.5 and started seeing the following exception when using virtualenvs:
Traceback (most recent call last):
  File "/home/rsyring/.virtualenvs/hllapi/bin/ppc", line 5, in <module>
    from pkg_resources import load_entry_point
  File "build/bdist.linux-i686/egg/pkg_resources.py", line 16, in <module>
  File "/home/rsyring/.virtualenvs/hllapi/lib/python2.7/re.py", line 105, in <module>
    import sre_compile
  File "/home/rsyring/.virtualenvs/hllapi/lib/python2.7/sre_compile.py", line 14, in <module>
    import sre_parse
  File "/home/rsyring/.virtualenvs/hllapi/lib/python2.7/sre_parse.py", line 17, in <module>
    from sre_constants import *
  File "/home/rsyring/.virtualenvs/hllapi/lib/python2.7/sre_constants.py", line 18, in <module>
    from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
Seems to be related to older binaries with a newer standard library.  Simple fix is to change into you virtualenv directory and run `virtualenv .`

Python Distribute is now Deprecated

Just came across the news today that Distribute has been merged into setuptools and deprecated as a project:

http://pythonhosted.org/setuptools/merge.html