Skip to content

Commit a27d523

Browse files
committed
some cleanup
1 parent 1210450 commit a27d523

File tree

9 files changed

+68
-69
lines changed

9 files changed

+68
-69
lines changed

src/pytest_databases/docker/cockroachdb.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
@pytest.fixture(scope="session")
19-
def xdist_cockroachdb_isolate() -> XdistIsolationLevel:
19+
def cockroachdb_xdist_isolation_level() -> XdistIsolationLevel:
2020
return "database"
2121

2222

@@ -34,7 +34,7 @@ def cockroachdb_driver_opts() -> dict[str, str]:
3434
@pytest.fixture(autouse=False, scope="session")
3535
def cockroachdb_service(
3636
docker_service: DockerService,
37-
xdist_cockroachdb_isolate: XdistIsolationLevel,
37+
cockroachdb_xdist_isolation_level: XdistIsolationLevel,
3838
cockroachdb_driver_opts: dict[str, str],
3939
) -> Generator[CockroachDBService, None, None]:
4040
def cockroachdb_responsive(_service: ServiceContainer) -> bool:
@@ -53,7 +53,7 @@ def cockroachdb_responsive(_service: ServiceContainer) -> bool:
5353
container_name = "cockroachdb"
5454

5555
worker_num = get_xdist_worker_num()
56-
if xdist_cockroachdb_isolate == "server":
56+
if cockroachdb_xdist_isolation_level == "server":
5757
container_name = f"container_name_{worker_num}"
5858

5959
db_name = f"pytest_{worker_num + 1}"

src/pytest_databases/docker/dragonfly.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616

1717
@pytest.fixture(scope="session")
18-
def xdist_dragonfly_isolate() -> XdistIsolationLevel:
18+
def xdist_dragonfly_isolation_level() -> XdistIsolationLevel:
1919
return "database"
2020

2121

@@ -53,10 +53,10 @@ def dragonfly_image() -> str:
5353
def dragonfly_service(
5454
docker_service: DockerService,
5555
dragonfly_image: str,
56-
xdist_dragonfly_isolate: XdistIsolationLevel,
56+
xdist_dragonfly_isolation_level: XdistIsolationLevel,
5757
) -> Generator[DragonflyService, None, None]:
5858
worker_num = get_xdist_worker_num()
59-
if xdist_dragonfly_isolate == "database":
59+
if xdist_dragonfly_isolation_level == "database":
6060
container_num = worker_num // 1
6161
name = f"dragonfly_{container_num + 1}"
6262
db = worker_num

src/pytest_databases/docker/keydb.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414
from pytest_databases._service import DockerService
1515

1616

17-
@pytest.fixture(scope="session")
18-
def xdist_keydb_isolate() -> XdistIsolationLevel:
19-
return "database"
20-
21-
2217
@dataclasses.dataclass
2318
class KeydbService(ServiceContainer):
2419
db: int
@@ -34,6 +29,11 @@ def keydb_responsive(service_container: ServiceContainer) -> bool:
3429
client.close()
3530

3631

32+
@pytest.fixture(scope="session")
33+
def xdist_keydb_isolation_level() -> XdistIsolationLevel:
34+
return "database"
35+
36+
3737
@pytest.fixture(scope="session")
3838
def keydb_port(keydb_service: KeydbService) -> int:
3939
return keydb_service.port
@@ -52,11 +52,11 @@ def keydb_image() -> str:
5252
@pytest.fixture(autouse=False, scope="session")
5353
def keydb_service(
5454
docker_service: DockerService,
55-
xdist_keydb_isolate: XdistIsolationLevel,
55+
xdist_keydb_isolation_level: XdistIsolationLevel,
5656
keydb_image: str,
5757
) -> Generator[KeydbService, None, None]:
5858
worker_num = get_xdist_worker_num()
59-
if xdist_keydb_isolate == "database":
59+
if xdist_keydb_isolation_level == "database":
6060
container_num = worker_num // 1
6161
name = f"keydb_{container_num + 1}"
6262
db = worker_num

src/pytest_databases/docker/mariadb.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@
1616
from pytest_databases._service import DockerService
1717

1818

19-
@pytest.fixture(scope="session")
20-
def xdist_mariadb_isolate() -> XdistIsolationLevel:
21-
return "database"
22-
23-
2419
@dataclass
2520
class MariaDBService(ServiceContainer):
2621
db: str
2722
user: str
2823
password: str
2924

3025

26+
@pytest.fixture(scope="session")
27+
def xdist_mariadb_isolation_level() -> XdistIsolationLevel:
28+
return "database"
29+
30+
3131
@contextlib.contextmanager
3232
def _provide_mysql_service(
3333
docker_service: DockerService,
@@ -99,13 +99,13 @@ def check(_service: ServiceContainer) -> bool:
9999
@pytest.fixture(autouse=False, scope="session")
100100
def mariadb113_service(
101101
docker_service: DockerService,
102-
xdist_mariadb_isolate: XdistIsolationLevel,
102+
xdist_mariadb_isolation_level: XdistIsolationLevel,
103103
) -> Generator[MariaDBService, None, None]:
104104
with _provide_mysql_service(
105105
docker_service=docker_service,
106106
image="mariadb:11.3",
107107
name="mariadb-11.3",
108-
isolation_level=xdist_mariadb_isolate,
108+
isolation_level=xdist_mariadb_isolation_level,
109109
) as service:
110110
yield service
111111

src/pytest_databases/docker/mssql.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
@pytest.fixture(scope="session")
19-
def xdist_mssql_isolate() -> XdistIsolationLevel:
19+
def xdist_mssql_isolation_level() -> XdistIsolationLevel:
2020
return "database"
2121

2222

@@ -42,7 +42,7 @@ def connection_string(self) -> str:
4242
@pytest.fixture(autouse=False, scope="session")
4343
def mssql_service(
4444
docker_service: DockerService,
45-
xdist_mssql_isolate: XdistIsolationLevel,
45+
xdist_mssql_isolation_level: XdistIsolationLevel,
4646
) -> Generator[MSSQLService, None, None]:
4747
password = "Super-secret1"
4848

@@ -65,7 +65,7 @@ def check(_service: ServiceContainer) -> bool:
6565
worker_num = get_xdist_worker_num()
6666
db_name = f"pytest_{worker_num + 1}"
6767
container_name = "mssql"
68-
if xdist_mssql_isolate == "server":
68+
if xdist_mssql_isolation_level == "server":
6969
container_name = f"{container_name}_{worker_num}"
7070

7171
with docker_service.run(

src/pytest_databases/docker/mysql.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@
1616
from pytest_databases.types import XdistIsolationLevel
1717

1818

19-
@pytest.fixture(scope="session")
20-
def xdist_mysql_isolate() -> XdistIsolationLevel:
21-
return "database"
22-
23-
2419
@dataclass
2520
class MySQLService(ServiceContainer):
2621
db: str
2722
user: str
2823
password: str
2924

3025

26+
@pytest.fixture(scope="session")
27+
def xdist_mysql_isolation_level() -> XdistIsolationLevel:
28+
return "database"
29+
30+
3131
@contextlib.contextmanager
3232
def _provide_mysql_service(
3333
docker_service: DockerService,
@@ -104,41 +104,41 @@ def mysql_service(mysql8_service: MySQLService) -> MySQLService:
104104
@pytest.fixture(autouse=False, scope="session")
105105
def mysql8_service(
106106
docker_service: DockerService,
107-
xdist_mysql_isolate: XdistIsolationLevel,
107+
xdist_mysql_isolation_level: XdistIsolationLevel,
108108
) -> Generator[MySQLService, None, None]:
109109
with _provide_mysql_service(
110110
image="mysql:8",
111111
name="mysql-8",
112112
docker_service=docker_service,
113-
isolation_level=xdist_mysql_isolate,
113+
isolation_level=xdist_mysql_isolation_level,
114114
) as service:
115115
yield service
116116

117117

118118
@pytest.fixture(autouse=False, scope="session")
119119
def mysql57_service(
120120
docker_service: DockerService,
121-
xdist_mysql_isolate: XdistIsolationLevel,
121+
xdist_mysql_isolation_level: XdistIsolationLevel,
122122
) -> Generator[MySQLService, None, None]:
123123
with _provide_mysql_service(
124124
image="mysql:5.7",
125125
name="mysql-57",
126126
docker_service=docker_service,
127-
isolation_level=xdist_mysql_isolate,
127+
isolation_level=xdist_mysql_isolation_level,
128128
) as service:
129129
yield service
130130

131131

132132
@pytest.fixture(autouse=False, scope="session")
133133
def mysql56_service(
134134
docker_service: DockerService,
135-
xdist_mysql_isolate: XdistIsolationLevel,
135+
xdist_mysql_isolation_level: XdistIsolationLevel,
136136
) -> Generator[MySQLService, None, None]:
137137
with _provide_mysql_service(
138138
image="mysql:5.6",
139139
name="mysql-56",
140140
docker_service=docker_service,
141-
isolation_level=xdist_mysql_isolate,
141+
isolation_level=xdist_mysql_isolation_level,
142142
) as service:
143143
yield service
144144

src/pytest_databases/docker/postgres.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ def _make_connection_string(host: str, port: int, user: str, password: str, data
2020
return f"dbname={database} user={user} host={host} port={port} password={password}"
2121

2222

23+
@pytest.fixture(scope="session")
24+
def xdist_postgres_isolation_level() -> XdistIsolationLevel:
25+
return "database"
26+
27+
2328
@dataclasses.dataclass
2429
class PostgresService(ServiceContainer):
2530
database: str
2631
password: str
2732
user: str
2833

2934

30-
@pytest.fixture(scope="session")
31-
def xdist_postgres_isolate() -> XdistIsolationLevel:
32-
return "database"
33-
34-
3535
@contextmanager
3636
def _provide_postgres_service(
3737
docker_service: DockerService,
@@ -82,97 +82,97 @@ def check(_service: ServiceContainer) -> bool:
8282
@pytest.fixture(autouse=False, scope="session")
8383
def postgres_11_service(
8484
docker_service: DockerService,
85-
xdist_postgres_isolate: XdistIsolationLevel,
85+
xdist_postgres_isolation_level: XdistIsolationLevel,
8686
) -> Generator[PostgresService, None, None]:
8787
with _provide_postgres_service(
8888
docker_service,
8989
image="postgres:11",
9090
name="postgres-11",
91-
xdist_postgres_isolate=xdist_postgres_isolate,
91+
xdist_postgres_isolate=xdist_postgres_isolation_level,
9292
) as service:
9393
yield service
9494

9595

9696
@pytest.fixture(autouse=False, scope="session")
9797
def postgres_12_service(
9898
docker_service: DockerService,
99-
xdist_postgres_isolate: XdistIsolationLevel,
99+
xdist_postgres_isolation_level: XdistIsolationLevel,
100100
) -> Generator[PostgresService, None, None]:
101101
with _provide_postgres_service(
102102
docker_service,
103103
image="postgres:12",
104104
name="postgres-12",
105-
xdist_postgres_isolate=xdist_postgres_isolate,
105+
xdist_postgres_isolate=xdist_postgres_isolation_level,
106106
) as service:
107107
yield service
108108

109109

110110
@pytest.fixture(autouse=False, scope="session")
111111
def postgres_13_service(
112112
docker_service: DockerService,
113-
xdist_postgres_isolate: XdistIsolationLevel,
113+
xdist_postgres_isolation_level: XdistIsolationLevel,
114114
) -> Generator[PostgresService, None, None]:
115115
with _provide_postgres_service(
116116
docker_service,
117117
image="postgres:13",
118118
name="postgres-13",
119-
xdist_postgres_isolate=xdist_postgres_isolate,
119+
xdist_postgres_isolate=xdist_postgres_isolation_level,
120120
) as service:
121121
yield service
122122

123123

124124
@pytest.fixture(autouse=False, scope="session")
125125
def postgres_14_service(
126126
docker_service: DockerService,
127-
xdist_postgres_isolate: XdistIsolationLevel,
127+
xdist_postgres_isolation_level: XdistIsolationLevel,
128128
) -> Generator[PostgresService, None, None]:
129129
with _provide_postgres_service(
130130
docker_service,
131131
image="postgres:14",
132132
name="postgres-14",
133-
xdist_postgres_isolate=xdist_postgres_isolate,
133+
xdist_postgres_isolate=xdist_postgres_isolation_level,
134134
) as service:
135135
yield service
136136

137137

138138
@pytest.fixture(autouse=False, scope="session")
139139
def postgres_15_service(
140140
docker_service: DockerService,
141-
xdist_postgres_isolate: XdistIsolationLevel,
141+
xdist_postgres_isolation_level: XdistIsolationLevel,
142142
) -> Generator[PostgresService, None, None]:
143143
with _provide_postgres_service(
144144
docker_service,
145145
image="postgres:15",
146146
name="postgres-15",
147-
xdist_postgres_isolate=xdist_postgres_isolate,
147+
xdist_postgres_isolate=xdist_postgres_isolation_level,
148148
) as service:
149149
yield service
150150

151151

152152
@pytest.fixture(autouse=False, scope="session")
153153
def postgres_16_service(
154154
docker_service: DockerService,
155-
xdist_postgres_isolate: XdistIsolationLevel,
155+
xdist_postgres_isolation_level: XdistIsolationLevel,
156156
) -> Generator[PostgresService, None, None]:
157157
with _provide_postgres_service(
158158
docker_service,
159159
image="postgres:16",
160160
name="postgres-16",
161-
xdist_postgres_isolate=xdist_postgres_isolate,
161+
xdist_postgres_isolate=xdist_postgres_isolation_level,
162162
) as service:
163163
yield service
164164

165165

166166
@pytest.fixture(autouse=False, scope="session")
167167
def postgres_17_service(
168168
docker_service: DockerService,
169-
xdist_postgres_isolate: XdistIsolationLevel,
169+
xdist_postgres_isolation_level: XdistIsolationLevel,
170170
) -> Generator[PostgresService, None, None]:
171171
with _provide_postgres_service(
172172
docker_service,
173173
image="postgres:17",
174174
name="postgres-17",
175-
xdist_postgres_isolate=xdist_postgres_isolate,
175+
xdist_postgres_isolate=xdist_postgres_isolation_level,
176176
) as service:
177177
yield service
178178

src/pytest_databases/docker/redis.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
from pytest_databases._service import DockerService
1515

1616

17-
@pytest.fixture(scope="session")
18-
def xdist_redis_isolate() -> XdistIsolationLevel:
19-
return "database"
20-
21-
2217
@dataclasses.dataclass
2318
class RedisService(ServiceContainer):
2419
db: int
2520

2621

22+
@pytest.fixture(scope="session")
23+
def xdist_redis_isolation_level() -> XdistIsolationLevel:
24+
return "database"
25+
26+
2727
def redis_responsive(service_container: ServiceContainer) -> bool:
2828
client = Redis(host=service_container.host, port=service_container.port)
2929
try:
@@ -53,10 +53,10 @@ def redis_image() -> str:
5353
def redis_service(
5454
docker_service: DockerService,
5555
redis_image: str,
56-
xdist_redis_isolate: XdistIsolationLevel,
56+
xdist_redis_isolation_level: XdistIsolationLevel,
5757
) -> Generator[RedisService, None, None]:
5858
worker_num = get_xdist_worker_num()
59-
if xdist_redis_isolate == "database":
59+
if xdist_redis_isolation_level == "database":
6060
container_num = worker_num // 1
6161
name = f"redis_{container_num + 1}"
6262
db = worker_num

0 commit comments

Comments
 (0)