Created
September 19, 2017 17:53
-
-
Save luanfonceca/77af40e2ddb6ef00010f95cc3e12ae0a to your computer and use it in GitHub Desktop.
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 date | |
from freezegun import freeze_time | |
from dateutil.relativedelta import relativedelta | |
class Replicant(): | |
def __init__(self, name, incept_date): | |
self.name = name | |
self.incept_date = incept_date | |
@property | |
def age(self): | |
return relativedelta(date.today(), self.incept_date).years | |
class TestReplicant(): | |
@freeze_time('2049-10-5') | |
def test_age(self): | |
replicant = Replicant( | |
name='Rick Deckard', | |
incept_date=date(year=1999, month=10, day=4) | |
) | |
assert replicant.age == 50 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment