Commit 662333ca authored by David Foucher's avatar David Foucher

FIX datetime test

parent 98928661
Pipeline #1508 passed with stage
in 1 minute and 16 seconds
...@@ -155,10 +155,10 @@ def test_insee_commune_to_departement(input, expected): ...@@ -155,10 +155,10 @@ def test_insee_commune_to_departement(input, expected):
@pytest.mark.parametrize( @pytest.mark.parametrize(
"input,expected", "input,expected",
[ [
((1999, 5, 20), 20), ((1998, 5, 20), 20),
((1999, 10, 8), 20), ((1998, 10, 8), 20),
((1998, 1, 1), 21), ((1998, 1, 1), 20),
((1998, 12, 31), 20), ((1998, 12, 31), 19),
], ],
) )
def test_calculate_age(input, expected, monkeypatch): def test_calculate_age(input, expected, monkeypatch):
...@@ -167,7 +167,6 @@ def test_calculate_age(input, expected, monkeypatch): ...@@ -167,7 +167,6 @@ def test_calculate_age(input, expected, monkeypatch):
def today(cls): def today(cls):
return datetime.datetime(2018, 10, 8) return datetime.datetime(2018, 10, 8)
#TO FIX patch does not work
monkeypatch.setattr(datetime, "date", mydate) monkeypatch.setattr(datetime, "date", mydate)
assert calculate_age(datetime.datetime(*input)) == expected assert calculate_age(datetime.datetime(*input)) == expected
......
import asyncio import asyncio
import datetime
import re import re
from datetime import date
from math import ceil from math import ceil
...@@ -39,7 +39,7 @@ EMPTY_VALUES = (None, "", set(), []) ...@@ -39,7 +39,7 @@ EMPTY_VALUES = (None, "", set(), [])
def calculate_age(born): def calculate_age(born):
today = date.today() today = datetime.date.today()
return today.year - born.year - ((today.month, today.day) < (born.month, born.day)) return today.year - born.year - ((today.month, today.day) < (born.month, born.day))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment