Note to self: Always version-lock your dependencies!



I was setting up a development copy of a client website on my computer the other day, and after I had cloned the repo, set up the database, and pip installed Django and all of the other python packages needed for the website, I faced a strange Exception coming from deep inside of one of my dependencies. After an embarrasingly long period of troubleshooting, I realized that when I specified my python dependencies, I neglected to include the version requirements for each package.


Mocking datetime in Python 2


Mocking dates is a well-known PITA with Python. But here's a quick explanation of how I worked around this deficiency.

Step 1: Add the date as a property to the production class. I had to refactor my code, and I suspect you will too. Before mocking this date, I was calling from the build_widget method.

from datetime import date

class WidgetWorker(object):
    date =
    def build_widget(self):
        return {'date_created':}

Subscribe to RSS - programming