#32403: When run test with off postgres database got `RuntimeError: generator
didn't yield` instead of connection error
----------------------------------+--------------------------------------
     Reporter:  Kazantcev Andrey  |                    Owner:  (none)
         Type:  Bug               |                   Status:  closed
    Component:  contrib.postgres  |                  Version:  3.2
     Severity:  Normal            |               Resolution:  needsinfo
     Keywords:  postgres db       |             Triage Stage:  Unreviewed
    Has patch:  0                 |      Needs documentation:  0
  Needs tests:  0                 |  Patch needs improvement:  0
Easy pickings:  0                 |                    UI/UX:  0
----------------------------------+--------------------------------------

Comment (by Kazantcev Andrey):

 Replying to [comment:1 Mariusz Felisiak]:
 > Thanks for the report, however the builtin
 `django.db.backends.postgresql` backend (on Python `3.9.0+` and `3.8.5`)
 raises `Connection refused` for me (as expected):
 > {{{
 > django.db.utils.OperationalError: could not connect to server:
 Connection refused
 >         Is the server running on host "localhost" (127.0.0.1) and
 accepting
 >         TCP/IP connections on port 5432?
 > }}}
 >
 > Can you share more details or a database configuration?

 Configuration
 ```
 DATABASES = {
     'default': {
         'ENGINE': 'django.db.backends.postgresql_psycopg2',
         'NAME': os.getenv('POSTGRESQL_NAME', 'postgres'),
         'USER': os.getenv('POSTGRESQL_USER', 'postgres'),
         'PASSWORD': os.getenv('POSTGRESQL_PASSWORD', 'postgres'),
         'HOST': os.getenv('POSTGRESQL_HOST', 'localhost'),
         'PORT': os.getenv('POSTGRESQL_PORT', '5432'),
         'OPTIONS': json.loads(os.getenv('POSTGRESQL_ENGINE_OPTIONS',
 '{}'))
     }
 }
 ```

 I found a problem. The problem is in [these
 
lines](https://github.com/django/django/blob/f9cfd346f0222d86bfbac26ef5455806965bae6b/django/db/backends/postgresql/base.py#L324-L325).
 If I have one connection and test expression in if return false then
 function just return without reraise exception. And `contextmanager`
 raises error `RuntimeError: generator didn't yield`

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32403#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.1ffc3daa8e227a0daafa1243e264eed2%40djangoproject.com.

Reply via email to