1
- from testcontainers .mysql import MySqlContainer
1
+ from testcontainers .postgres import PostgresContainer
2
2
3
3
from Spybot2 import settings
4
4
5
5
from xmlrunner .extra .djangotestrunner import XMLTestRunner
6
6
7
7
8
8
class TestContainerRunner (XMLTestRunner ):
9
- mysql_container : MySqlContainer = None
9
+ postgres_container : PostgresContainer = None
10
10
11
11
def setup_databases (self , ** kwargs ):
12
- self .mysql_container = MySqlContainer (image = "mariadb:11.0 " )
13
- self .mysql_container .start ()
12
+ self .postgres_container = PostgresContainer (image = "postgres:17.2 " )
13
+ self .postgres_container .start ()
14
14
15
15
db_connection_settings = {
16
- 'USER' : 'root' ,
17
- 'PASSWORD' : self .mysql_container . root_password ,
18
- 'HOST' : self .mysql_container .get_container_host_ip ().replace ("localhost" , "127.0.0.1" ),
19
- 'PORT' : self .mysql_container .get_exposed_port (3306 ),
16
+ 'USER' : self . postgres_container . username ,
17
+ 'PASSWORD' : self .postgres_container . password ,
18
+ 'HOST' : self .postgres_container .get_container_host_ip ().replace ("localhost" , "127.0.0.1" ),
19
+ 'PORT' : self .postgres_container .get_exposed_port (self . postgres_container . port ),
20
20
}
21
21
settings .DATABASES ['default' ].update (db_connection_settings )
22
22
@@ -25,4 +25,4 @@ def setup_databases(self, **kwargs):
25
25
def teardown_databases (self , old_config , ** kwargs ):
26
26
super ().teardown_databases (old_config , ** kwargs )
27
27
28
- self .mysql_container .stop ()
28
+ self .postgres_container .stop ()
0 commit comments