-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bizarre errors from Pandas when using the decorator #98
Comments
Which version of freezegun are you on? We've had this issue in the past, but I thought it was fixed with #13 |
Installed current pip version today
|
Ah, I have read the other issue and I see it is the same symptom but a different case It was fixed in #13 for the case of My case is a frozen test that contains code that imports Pandas Is there any insight into why Pandas spits the dummy? Is it something that could be solved? I'm currently using |
I think Pandas does some C-level manipulation or use of the datetime/time modules. I've dug into it a bit, but not found a way that we could work around it. |
Just ran into this problem too – my frozen test code was importing Pandas, and Pandas import failed with
I got it to work by explicitly importing Pandas before the test code runs. |
I'm going to close this. Please reopen if you confirm it is still an issue |
FYI, this still seems to be an issue, even using the latest versions of Pandas and freezegun: @freeze_time("2020-01-01")
def test_freeze_time_pandas():
import pandas Python 2:
Python 3:
This is admittedly a contrived example, and in my case it seems like I can avoid this by using |
To give a concrete example of this suggestion from @ze-phyr-us:
I was able to do this by adding |
Why this issue is closed? It's still a problem. Could you please reopen @spulec ? |
There are multiple issues with freezegun: First this error: spulec/freezegun#98 (comment) It can be solved by importing `pandas` before the tests are run. Not very clean but it works. And more importantly this error that doesn't seem to have a workaround other than patching freezegun or DRF: spulec/freezegun#382
Apparently the issue can be fixed using workaround by importing |
Importing pandas early is not always a good idea, since it consumes a lot of memory without actually doing anything. If you have a project that can be invoked in many different ways (think of one code base that can run both as a webserver and as a task queue processor in Docker containers) then you want to avoid that pandas import if you're never going to need it. You don't always have the option of splitting the code base. My workaround is to have a conditional early import when running tests. |
Wanted to use this but I get bizarre errors from Pandas when I add the decorator to my test function.
The test and the code being tested do not execute any Pandas methods directly, but one of my project modules imports pandas - the error is occurring at import time.
The text was updated successfully, but these errors were encountered: