Skip to content

Commit 9384bca

Browse files
committed
move environment tests into test case
1 parent 5028967 commit 9384bca

File tree

1 file changed

+47
-46
lines changed

1 file changed

+47
-46
lines changed

tests/verify_environment.py

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from django import VERSION
44
from django.db import connection
55
import typing as t
6-
from importlib.util import find_spec
6+
from django.test import TestCase
77

88

99
def get_postgresql_version() -> t.Tuple[int, ...]:
@@ -22,54 +22,55 @@ def get_mysql_version():
2222
print("MySQL version:", version[0])
2323

2424

25-
def test():
26-
# verify that the environment is set up correctly - this is used in CI to make
27-
# sure we're testing against the dependencies we think we are
25+
class TestEnvironment(TestCase):
26+
def test(self):
27+
# verify that the environment is set up correctly - this is used in CI to make
28+
# sure we're testing against the dependencies we think we are
2829

29-
rdbms = os.environ["RDBMS"]
30-
expected_python = os.environ["TEST_PYTHON_VERSION"]
31-
expected_django = os.environ["TEST_DJANGO_VERSION"]
32-
expected_db_ver = os.environ.get("TEST_DATABASE_VERSION", None)
33-
expected_client = os.environ.get("TEST_DATABASE_CLIENT_VERSION", None)
30+
rdbms = os.environ["RDBMS"]
31+
expected_python = os.environ["TEST_PYTHON_VERSION"]
32+
expected_django = os.environ["TEST_DJANGO_VERSION"]
33+
expected_db_ver = os.environ.get("TEST_DATABASE_VERSION", None)
34+
expected_client = os.environ.get("TEST_DATABASE_CLIENT_VERSION", None)
3435

35-
expected_python = tuple(int(v) for v in expected_python.split(".") if v)
36-
assert sys.version_info[: len(expected_python)] == expected_python, (
37-
f"Python Version Mismatch: {sys.version_info[: len(expected_python)]} != "
38-
f"{expected_python}"
39-
)
36+
expected_python = tuple(int(v) for v in expected_python.split(".") if v)
37+
assert sys.version_info[: len(expected_python)] == expected_python, (
38+
f"Python Version Mismatch: {sys.version_info[: len(expected_python)]} != "
39+
f"{expected_python}"
40+
)
4041

41-
expected_django = tuple(int(v) for v in expected_django.split(".") if v)
42-
assert VERSION[: len(expected_django)] == expected_django, (
43-
f"Django Version Mismatch: {VERSION[: len(expected_django)]} != "
44-
f"{expected_django}"
45-
)
42+
expected_django = tuple(int(v) for v in expected_django.split(".") if v)
43+
assert VERSION[: len(expected_django)] == expected_django, (
44+
f"Django Version Mismatch: {VERSION[: len(expected_django)]} != "
45+
f"{expected_django}"
46+
)
4647

47-
if expected_db_ver:
48-
if rdbms == "postgres":
49-
if expected_db_ver == "latest":
50-
# todo
51-
pass
52-
else:
53-
expected_version = tuple(
54-
int(v) for v in expected_db_ver.split(".") if v
55-
)
56-
assert (
57-
expected_version
58-
== get_postgresql_version()[: len(expected_version)]
59-
)
60-
if expected_client == "psycopg3":
61-
import psycopg
48+
if expected_db_ver:
49+
if rdbms == "postgres":
50+
if expected_db_ver == "latest":
51+
# todo
52+
pass
53+
else:
54+
expected_version = tuple(
55+
int(v) for v in expected_db_ver.split(".") if v
56+
)
57+
assert (
58+
expected_version
59+
== get_postgresql_version()[: len(expected_version)]
60+
)
61+
if expected_client == "psycopg3":
62+
import psycopg
6263

63-
assert psycopg.__version__[0] == "3"
64-
else:
65-
import psycopg2
64+
assert psycopg.__version__[0] == "3"
65+
else:
66+
import psycopg2
6667

67-
assert psycopg2.__version__[0] == "2"
68-
elif rdbms == "mysql":
69-
pass
70-
elif rdbms == "mariadb":
71-
pass
72-
elif rdbms == "sqlite":
73-
pass
74-
elif rdbms == "oracle":
75-
pass
68+
assert psycopg2.__version__[0] == "2"
69+
elif rdbms == "mysql":
70+
pass
71+
elif rdbms == "mariadb":
72+
pass
73+
elif rdbms == "sqlite":
74+
pass
75+
elif rdbms == "oracle":
76+
pass

0 commit comments

Comments
 (0)