-
Notifications
You must be signed in to change notification settings - Fork 346
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
AttributeError: 'Module' object has no attribute '_obj' #386
Comments
You are accessing the DB when defining your form already (during import):
That is probably not what you want, since then the list is (probably) stale. The |
In pytest-django the DB blocker is more strict, and I'd say that it probably found some issue in your code. I could imagine to handle this better in this specific case, so that not the |
Can you post the full output from pytest, please? |
The issue seems to be tied to pytest-django not pytest
|
I use --reuse-db and if I where to hazard a guess the issue is coming from here: in pytest_django/db_reuse.py I will need to do some more digging to verify. |
It is more strict now. This is expected to happen. But the error should not be about the Let's wait for @pelme to chime in. |
@aklaver Your code does not do what you expect. As @blueyed pointed out, the line The code does not do what you intend it to do. pytest-django was buggy and accidentally did not throw an error prior to 3.0.0. You need to change your code to have the query run at a later time (at the time of a request). If you need help, provide the full code of your form class and I can suggest how you can change it.
looks like an issue with pytest. Let's create a pytest issue for that error and then we can close this issue. |
Per @blueyed and your (@pelme ) suggestions I moved the choice generation into the init |
Seems to be fixed in pytest. |
Django 1.8.14
pytest==3.0.1
pytest-django-3.0.0
This code(a simplified version of real code):
Gives this Traceback
The above combination of software works on other test files. Using pytest-django==2.9.1 also works
The text was updated successfully, but these errors were encountered: