Hello! Thanks for commenting!
It's been explained well in the SO thread, but basically the problem here is that the data is initialised when you execute the import statement, so the only way for the date to be mocked is actually to mock it before the file is imported (which is why it works when you mock it in the setup file).
If the date was created in your function instead of at the top level of the code, the mock would work.
Does that make it clearer?
Hello! Thanks for commenting!
It's been explained well in the SO thread, but basically the problem here is that the data is initialised when you execute the import statement, so the only way for the date to be mocked is actually to mock it before the file is imported (which is why it works when you mock it in the setup file).
If the date was created in your function instead of at the top level of the code, the mock would work.
Does that make it clearer?
Yes, it makes totally sense, thanks Quentin.
And thanks again for your post!