3
3
from django import VERSION
4
4
from django .db import connection
5
5
import typing as t
6
- from importlib . util import find_spec
6
+ from django . test import TestCase
7
7
8
8
9
9
def get_postgresql_version () -> t .Tuple [int , ...]:
@@ -22,54 +22,55 @@ def get_mysql_version():
22
22
print ("MySQL version:" , version [0 ])
23
23
24
24
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
28
29
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 )
34
35
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
+ )
40
41
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
+ )
46
47
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
62
63
63
- assert psycopg .__version__ [0 ] == "3"
64
- else :
65
- import psycopg2
64
+ assert psycopg .__version__ [0 ] == "3"
65
+ else :
66
+ import psycopg2
66
67
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