Dev diary, day 2: testing

Today I learned some stuff about testing in Python. Since I've been working with Ruby for the past couple of years, and the Ruby community is pretty serious about testing, I've come to rely on it a lot to help me code with confidence.

In my current team we have a lot of tests, written with Python's unittest library, and ran with nose ("is nicer testing for python"). These two libraries remind me of Ruby's Test:Unit, and how test are run on apps using rake, like I've shown here on a previous post.

I've run into some problems while trying to load the code I want to test on my test file, using the "import". It seems that, when using Python, importing relative paths is Not a Good Idea™, as the PEP8 clearly states:

"Implicit relative imports should never be used and have been removed in Python 3."

This, together with a lot of answered questions on Stack Overflow, that state the same, has lead me to find a better solution for this. For now, no green test today :-(

One thing I found amusing about PEP8 is the title of what follows the introduction, which comes from a quote by Ralph Waldo Emerson, an American philosopher:

"A foolish consistency is the hobgoblin of little minds, adored by little statesmen and philosophers and divines."

You can read more about it on Wikipedia, and to entice you, here's a picture of a hobgoblin:

See you tomorrow!