Python: testing beyond exceptions

Recently working on some code I was doing some basic tests that checked for an exception being raised. The tests looked like this: def test_user_identification_is_valid_option(self): with self.assertRaises(ValueError): example_seller(products=[ 'id': 'hai', 'description': 'a description', 'recurrence': None, 'user_identification': True, }]) def test_…

Fake SMTP server with Python

The other day a colleague was testing some code which relied on sending mail to a local mailserver and it was failing when the mailserver couldn't be found. Needing to install postfix seemed overkill so I decided to look into what could be done to make a fake smtp service.…

Simple Switching of VirtualEnv Environments

If you're using Python for any kind of serious development virtualenv is highly recommended as a way to sandbox dependencies and allow you to run different libraries and or python versions for different projects. For more on Virtualenv and how to use it see VirutalEnv on PyPi I wanted a…

Install lxml on OSX

Thanks to this post on lxml from Ian Bicking I've found the following command is all that's required to install lxml on Mac OSX: STATIC_DEPS=true easy_install 'lxml>=2.2beta4'…

Python 3.0 Released

So Python 3.0 is out - here's the list of what's new. There's a lot in there and it specifically say it's incomplete (here's the changelog for comparison.). What I'm most concerned about is the thought of having to maintain several versions of code to work with python 2.…