@@ -159,32 +159,32 @@ def test_xdist_with_reuse(django_testdir):
159
159
160
160
from .app.models import Item
161
161
162
- def _check(settings):
162
+ def _check(settings, worker_id ):
163
163
# Make sure that the database name looks correct
164
164
db_name = settings.DATABASES['default']['NAME']
165
- assert db_name.endswith('_gw0') or db_name.endswith('_gw1' )
165
+ assert db_name == 'test_custom_db_name_{}'.format(worker_id )
166
166
167
167
assert Item.objects.count() == 0
168
168
Item.objects.create(name='foo')
169
169
assert Item.objects.count() == 1
170
170
171
171
172
172
@pytest.mark.django_db
173
- def test_a(settings):
174
- _check(settings)
173
+ def test_a(settings, worker_id ):
174
+ _check(settings, worker_id )
175
175
176
176
177
177
@pytest.mark.django_db
178
- def test_b(settings):
179
- _check(settings)
178
+ def test_b(settings, worker_id ):
179
+ _check(settings, worker_id )
180
180
181
181
@pytest.mark.django_db
182
- def test_c(settings):
183
- _check(settings)
182
+ def test_c(settings, worker_id ):
183
+ _check(settings, worker_id )
184
184
185
185
@pytest.mark.django_db
186
- def test_d(settings):
187
- _check(settings)
186
+ def test_d(settings, worker_id ):
187
+ _check(settings, worker_id )
188
188
"""
189
189
)
190
190
@@ -270,7 +270,7 @@ def test_sqlite_database_renamed(self, django_testdir):
270
270
from django.db import connections
271
271
272
272
@pytest.mark.django_db
273
- def test_a():
273
+ def test_a(worker_id ):
274
274
(conn_db2, conn_default) = sorted(
275
275
connections.all(),
276
276
key=lambda conn: conn.alias,
@@ -288,7 +288,7 @@ def test_a():
288
288
289
289
assert conn_db2.vendor == 'sqlite'
290
290
db_name = conn_db2.creation._get_test_db_name()
291
- assert db_name.startswith('test_custom_db_name_gw' )
291
+ assert db_name == 'test_custom_db_name_{}'.format(worker_id )
292
292
"""
293
293
)
294
294
@@ -377,13 +377,15 @@ def test_db_with_tox_suffix(self, django_testdir, monkeypatch):
377
377
from django.db import connections
378
378
379
379
@pytest.mark.django_db
380
- def test_inner():
380
+ def test_inner(worker_id ):
381
381
382
382
(conn, ) = connections.all()
383
383
384
384
assert conn.vendor == 'sqlite'
385
385
db_name = conn.creation._get_test_db_name()
386
- assert db_name.startswith('test_custom_db_name_py37-django22_gw')
386
+ assert db_name == 'test_custom_db_name_py37-django22_{}'.format(
387
+ worker_id,
388
+ )
387
389
"""
388
390
)
389
391
0 commit comments