tags:

views:

37

answers:

2

When I try to run

manage.py test

a database password prompt shows.

Previously, tests would run without me having to enter the db password manaually. I just updated my database to postgres 8.4. I assume it's some setting I'm forgetting.

How can I configure it to run tests without asking for the password?

Additional Info:

I created the database with the user 'postgres', but am accessing in django with the user, 'postgis'. I checked the permissions of these users, and they are the same.

When running the test the db and tables get created fine (no password requested). It's only when it installs 'Custom SQL' that the password is requested.

RESOLUTION

As Carl pointed out the ~/.pgpass file [*nix] and %APPDATA%\postgresql\pgpass.conf (where %APPDATA% refers to the Application Data subdirectory in the user's profile) [windows] allows you to configure databases so you don't need to enter a password each time.

See the postgres documentation: The Password File

I checked my configuration and it looks like this file was/is auto-created. I updated my password file and now django tests run without the need to manually enter a password on each custom sql installation.

A: 

I assume it's some setting I'm forgetting.

Not trying to make a fool out of you, but sometimes simple solutions are overlooked: Did you set the DATABASE_PASSWORD setting in your settings.py file?

Roman Stolper
No, got that one. runserver runs fine, and don't have issues connecting through shell. Just when running tests.
monkut
+1  A: 

Django tests use a different database; your DATABASE_NAME setting with "_test" appended. My first guess would be that somewhere in your Postgres authentication config (either in pg_hba.conf or in a ~/.pgpass file), you are allowing access to DATABASE_NAME with no password, but you don't have the same config for DATABASE_NAME_test.

Carl Meyer
Thanks, I'll take a look. I didn't do anything specifically before that I recall in the postgres configuration, but it's likely that I didn't set it up the same way.
monkut