Submitted by northben on Sun, 05/03/2015 - 21:38
Background:
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.
Problem:
Submitted by northben on Thu, 03/12/2015 - 10:55
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 date.today() from the build_widget method.
from datetime import date
class WidgetWorker(object):
date = date.today()
def build_widget(self):
return {'date_created': self.date}