Created
April 30, 2015 23:38
-
-
Save eswald/098120b5aca16d01a080 to your computer and use it in GitHub Desktop.
TimestampMixin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime, timedelta | |
class TimestampMixin(object): | |
r'''Adds assertTimestamped to TestCase classes. | |
Checks that the given field contains a time between the beginning of | |
the test run and the assertion. | |
'''#"""#''' | |
def setUp(self): | |
super(TimestampMixin, self).setUp() | |
self.started = datetime.now() | |
def assertTimestamped(self, when, delta=timedelta()): | |
self.assertIsNotNone(when) | |
self.assertLessEqual(self.started + delta, when) | |
self.assertLessEqual(when, datetime.now() + delta) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment