Open rfleschenberg opened 7 years ago
Hi @rfleschenberg , Could you please share your failing tests in order to try to fix it. Thanks
@khchine5: I'd have to share the whole project, which I can't right now. But I will create a reproducible test case ASAP.
BTW, you should be able to reproduce this with any testcase that uses a model with a JSONField, I think. But I will try to send a testcase tomorrow.
To reproduce the issue:
pip install psycopg2
Change your settings:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'djangoshop',
}
}
You should get this:
django.db.utils.OperationalError: FATAL: database "djangoshop" does not exist
This is wrong, because it refers to the default database, not the test database. The tests should not rely on the default database being present.
Can we just document that we require Postgres >= 9.4 and psycopg >= 2.5.4? This would make the code much simpler.
Yes, I think it could be a good idea. but in the other hand ,it could be more complicated for the end developer and to run demo projects.
An other point about testing with a postgres database , Django offers the possibility to specify the database's name when testing. We need also to grand to the database user write access to our testing database. See : https://docs.djangoproject.com/es/1.10/topics/testing/overview/#the-test-database
We can hande this on travis, so we don't have to change anything for our users. We just need to use an environment var or a separate settings module and modify .travis-ci.yml
:)
Traceback below.
The problem seems to be that we are calling
connection.cursor()
inshop/models/fields.py
at module level, and that uses the connection to the default database, not the test database. I will investigate this ASAP.