January 23, 2013

Python Unit Testing Tutorial (PyMOTW unittest update)

tl;dr: an update to PyMOTW for `unittest` in Python 3: Python Unit Testing Tutorial.


When I was learning programming in Python, Doug Hellmann's 'PyMOTW' (Python Module Of The Week) blog-series was one of the best resources to learn Python's standard library.

His series later culminated in the book: 'The Python Standard Library By Example'.

The PyMOTW entry on `unittest` was a great introduction to unit testing in Python. Since the PyMOTW version is getting quite outdated, I updated the `unittest` module entry.

This new version includes some edits and updates to the text, and all code and examples have been updated to reflect Python 3.3.

Have a look at my updated Python 3.3 version:
'Python Unit Testing Tutorial'


license: Creative Commons Attribution, Non-commercial, Share-alike 3.0


say no to bugs...

2 comments:

Anonymous said...

I think this is great. It's good work.

Of course, unittest has issues. Since it's based on XUnit, it isn't (very) pythonic, and runs into conflicts with PEP8 and the like.

I think what is missing is an extended tutorial that dives into using nose for python unit testing and provides a best practices way of doing unit tests.

Right now, those learning python can only delve into the developer API documentation for Mock, Nose, or whatever module they are coding and hope to stumble upon an example that helps them accomplish what they need.

Perhaps this is something I will work on in the future.

Carl Trachte said...

Nit - the lady bug is way to beautiful and attractive. I want one. The idea of the post is that bugs in your software are a bad thing. You need an uglier bug graphic to get your point across. Sorry, this has nothing to do with the craft of testing or debugging :-(