I'm trying to patch a function called get_datetime()
.
The real date time get_datetime()
is located under bobs/utils/dtutils
and does:
def get_datetime() -> datetime:
return datetime.now()
this gets used in another place under bobs/generation
where globally in the generation.py
file i do:
from utils.dtutils import get_datetime
NAME = f"""{KMTER}/{get_datetime().strftime('%Y-%m-%d')}/dadsdge.fs"""
in the monkey patch i do:
monkey_patch.setattr(
"bobs.generation.get_datetime",
datetime.datetime(2021, 11, 18),
)
this doesn't work. I still get now()
returned.
I also tried patching bobs.utils.dtutils.get_datetime
to no avail either. It definitely finds it because if i make up the function name it says module does not contain bla
, so i don't understand why i'm not seeing it set...
get_datetime
in the first place? Seems like an unnecessary level of indirection (even if you go with the simpler definitionget_datetime = datetime.now
). – chepner