Using the **old** config **works** fine in both runserver and test.
Using the **new** config works for runserver but **fails** for test.
In settings I have :-
{{{#!python
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'OPTIONS': {
'service': 'yfsm_pgdb',
'passfile': '.yfsm_pgpass',
},
},
}
}}}
I have the user password entry allowing login to any database (using `*`)
I have also tried adding an entry with `test_dbname`. I also tried adding
an entry in .pg_service.conf as `[test_yfsm_pgdb]`
running tests I see `django.db.utils.OperationalError: fe_sendauth: no
password supplied` indicating that the password file is not used.
It would appear that when testing, the new OPTIONS settings are ignored.
--
Ticket URL: <https://code.djangoproject.com/ticket/33685>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by Shane Ambler):
Looking at the pull request for the OPTIONS change, I find that I can use
the service name `django_test`. This does not appear to be documented
anywhere.
While I wouldn't initially agree with using one login for testing all
projects, use of this pg service name needs to be documented.
--
Ticket URL: <https://code.djangoproject.com/ticket/33685#comment:1>
* component: Testing framework => Documentation
--
Ticket URL: <https://code.djangoproject.com/ticket/33685#comment:2>
* component: Documentation => Testing framework
--
Ticket URL: <https://code.djangoproject.com/ticket/33685#comment:3>
Comment (by Shane Ambler):
I failed to get my setting file right when I checked that, the use of the
`django_test` service name is part of the django project tests.
The use of postgresql service name still appears broken with testing
--
Ticket URL: <https://code.djangoproject.com/ticket/33685#comment:4>
* status: new => closed
* resolution: => invalid
Comment:
If you want to user PostgreSQL's password files, all required databases
must be included, i.e. `postgres`, `dbname`, `test_dbname`, e.g. the
following configuration works for me
{{{
localhost:5432:postgres:postgres_username:SeCrEtPassworD
localhost:5432:dbname:postgres_username:SeCrEtPassworD
localhost:5432:test_dbname:postgres_username:SeCrEtPassworD
}}}
`settings.py`:
{{{#!python
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'HOST': 'localhost',
'PORT': 5432,
'NAME': 'dbname',
'USER': 'postgres_username',
'OPTIONS': {
'passfile': '.custompgpass',
}
},
}
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33685#comment:5>
Comment (by Shane Ambler):
Replying to [comment:5 Mariusz Felisiak]:
> If you want to user PostgreSQL's password files, all required databases
must be included, i.e. `postgres`, `dbname`, `test_dbname`, e.g. the
following configuration works for me
> {{{
> localhost:5432:postgres:postgres_username:SeCrEtPassworD
> localhost:5432:dbname:postgres_username:SeCrEtPassworD
> localhost:5432:test_dbname:postgres_username:SeCrEtPassworD
> }}}
Yes, I tried both the `test_dbname` and `*` to match any dbname and it
still fails.
> `settings.py`:
> {{{#!python
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.postgresql',
> 'HOST': 'localhost',
> 'PORT': 5432,
> 'NAME': 'dbname',
> 'USER': 'postgres_username',
> 'OPTIONS': {
> 'passfile': '.custompgpass',
> }
> },
> }
> }}}
While you are maintaining both old and new config variations, all will
continue to work for you.
If you remove the old, no longer documented, settings of `HOST` `PORT`
`NAME` `USER` then your setup will work for `runserver` but not `test`
The pg docs [https://docs.djangoproject.com/en/4.0/ref/databases
/#postgresql-notes-1] only documents the new method of specifying
`service` and `passfile` in the `OPTIONS` - this documented setup **does
not support running tests** with postgresql databases.
--
Ticket URL: <https://code.djangoproject.com/ticket/33685#comment:6>
* status: closed => new
* resolution: invalid =>
--
Ticket URL: <https://code.djangoproject.com/ticket/33685#comment:7>