Open electroniceagle opened 8 years ago
Another point, the code that is hitting this in a before.all hook. This code appears to be executing against the production database:
@before.all
def _cleanup_user_models():
"""
Clean up possibly modified user tables in case
a user exits uncleanly. Control-c from pdb causes
data to be left in tables, for example.
"""
Session.objects.all().delete()
EmailAddress.objects.all().delete()
UserProfile.objects.all().delete()
User.objects.all().delete()
And the bug only appears when executing a specific feature file. Here is the derived command from my makefile:
./manage.py harvest --pdb --attr=\!not_site_awesim --keepdb --color -v 3 --logging-level=INFO --all-modules site_common/features/sessions.feature
I did not verify this but won't be surprised if this is inherited from django-nose. I am currently investigating if it would be feasible to switch away the whole project from Nose to either Py.test, Nose 2 or plain unittest.
Py.test seems to have a significant following, but I don't have much experience with nose or Py.test, so it is hard for me to compare.
I was reading over py.test and trolling the issues and came across this: https://github.com/pytest-dev/pytest-django/pull/182
Our bug might be triggered by django-cms opening the database very early. The proposed patches in both testing tools haven't been picked up probably because this is such a corner case.
This looks similar to aloetesting/aloe#118. Are you running a single feature or letting Aloe/Nose discover them?
@electroniceagle can you please try pure-unittest
branch of both Aloe and Aloe-Django (https://github.com/aloetesting/aloe/pull/117, #50) and see if the problem still exists?
If you use --keepdb, aloe will use your production database 'foo' rather than 'test_foo' in some circumstances. I think I've hit this bug in django-nose using --keepdb: https://github.com/django-nose/django-nose/issues/76
I only noticed this because postgresql hit a constraint error on a table that does not currently exist in Django (we removed the app, but forgot to clean the tables).
Despite the connection claiming it is connected to the 'test_site_awesim' database, the constraint error is for a table that only exists in my local copy of our production database.
Here is our current config.
Our workaround is to manually prepend 'test' to the NAME in the DATABASES setting.