Make django an optional dependency when running unittests (#166)

Fixes: #165
This commit is contained in:
Matt Seymour 2022-05-29 10:31:34 +01:00 committed by GitHub
parent 931a4e4198
commit b9cc1e47b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,7 +1,10 @@
import os
import unittest
from django import VERSION as DJANGO_VERSION
try:
from django import VERSION as DJANGO_VERSION
except ImportError:
DJANGO_VERSION = None
import dj_database_url
@ -10,7 +13,7 @@ POSTGIS_URL = "postgis://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compu
# Django deprecated the `django.db.backends.postgresql_psycopg2` in 2.0.
# https://docs.djangoproject.com/en/2.0/releases/2.0/#id1
EXPECTED_POSTGRES_ENGINE = "django.db.backends.postgresql"
if DJANGO_VERSION < (2, 0):
if DJANGO_VERSION and DJANGO_VERSION < (2, 0):
EXPECTED_POSTGRES_ENGINE = "django.db.backends.postgresql_psycopg2"