summaryrefslogtreecommitdiff
path: root/tests/backends
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2022-12-08 14:31:35 +0100
committerGitHub <noreply@github.com>2022-12-08 14:31:35 +0100
commit9da2210f121085e998dc7cedb783bc4568390b92 (patch)
tree3cf0510dbe311a5d1051f3d39799a9eea3b7996d /tests/backends
parentcbc0fb370583c6371eb2901f752ce286f008a6a4 (diff)
downloaddjango-9da2210f121085e998dc7cedb783bc4568390b92.tar.gz
Avoided direct mocking of psycopg2.__version__ in test_correct_extraction_psycopg2_version().
Diffstat (limited to 'tests/backends')
-rw-r--r--tests/backends/postgresql/tests.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/tests/backends/postgresql/tests.py b/tests/backends/postgresql/tests.py
index f056162454..d375bd2b8c 100644
--- a/tests/backends/postgresql/tests.py
+++ b/tests/backends/postgresql/tests.py
@@ -291,12 +291,14 @@ class Tests(TestCase):
"::citext", do.lookup_cast(lookup, internal_type=field_type)
)
- def test_correct_extraction_psycopg2_version(self):
- from django.db.backends.postgresql.base import psycopg2_version
+ def test_correct_extraction_psycopg_version(self):
+ from django.db.backends.postgresql.base import Database, psycopg2_version
- with mock.patch("psycopg2.__version__", "4.2.1 (dt dec pq3 ext lo64)"):
+ with mock.patch.object(Database, "__version__", "4.2.1 (dt dec pq3 ext lo64)"):
self.assertEqual(psycopg2_version(), (4, 2, 1))
- with mock.patch("psycopg2.__version__", "4.2b0.dev1 (dt dec pq3 ext lo64)"):
+ with mock.patch.object(
+ Database, "__version__", "4.2b0.dev1 (dt dec pq3 ext lo64)"
+ ):
self.assertEqual(psycopg2_version(), (4, 2))
@override_settings(DEBUG=True)