I was doing the following for a Django form definition (embarrassing, yes):
class DealAdvancedSearchForm(forms.Form): weekday_choices = [ ['monday', 'Monday'], ['tuesday', 'Tuesday'], ['wednesday', 'Wednesday'], ['thursday', 'Thursday'], ['friday', 'Friday'], ['saturday', 'Saturday'], ['sunday', 'Sunday'], ] weekday_index = date.today().weekday() weekday_choices[weekday_index][1] += ' (Today)' weekday_choices[weekday_index+1][1] += ' (Tomorrow)' weekday = forms.ChoiceField(label='Day of the week', choices=weekday_choices, required=False) As you probably guessed by now, this works fine as long as date.today() does not change. All my tests passed. However, once the date changes, it is incorrectly keeping initial date's choice marked as today.
I have since figured out how dumb this was and have moved the code into the __init__ method.
Now I want to write a test for it. Does anyone know how would I test that the correct weekday is marked as (Today) when the date changes?