You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the cursor()/chunked_cursor() methods of a connection had already
been monkey patched by some other code before wrap_cursor() was called,
unwrap_cursor() would undo the previous monkey patch as well as the one
performed by wrap_cursor().
This can occur when testing if multiple databases are defined but only
some of them are allowed to be used by the tests. [1] Django's
SimpleTestCase wraps the connections for any disallowed databases to
raise an exception if they are accessed. [2] Without this commit,
unwrap_cursor() was undoing Django's monkey patch, resulting in an
exception when Django tried to undo its monkey patch which was no longer
there.
Update unwrap_cursor() to preserve a previous monkey patch if present.
[1] https://docs.djangoproject.com/en/stable/topics/testing/tools/#django.test.SimpleTestCase.databases
[2] https://github.com/django/django/blob/ce586ed6931092d3a5f06df9031cdeb891793ddb/django/test/testcases.py#L350
0 commit comments