@@ -159,32 +159,34 @@ 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')
166
-
165
+ assert db_name == (
166
+ 'test_pytest_django_should_never_get_accessed_inner_inner_{}'
167
+ .format(worker_id)
168
+ )
167
169
assert Item.objects.count() == 0
168
170
Item.objects.create(name='foo')
169
171
assert Item.objects.count() == 1
170
172
171
173
172
174
@pytest.mark.django_db
173
- def test_a(settings):
174
- _check(settings)
175
+ def test_a(settings, worker_id ):
176
+ _check(settings, worker_id )
175
177
176
178
177
179
@pytest.mark.django_db
178
- def test_b(settings):
179
- _check(settings)
180
+ def test_b(settings, worker_id ):
181
+ _check(settings, worker_id )
180
182
181
183
@pytest.mark.django_db
182
- def test_c(settings):
183
- _check(settings)
184
+ def test_c(settings, worker_id ):
185
+ _check(settings, worker_id )
184
186
185
187
@pytest.mark.django_db
186
- def test_d(settings):
187
- _check(settings)
188
+ def test_d(settings, worker_id ):
189
+ _check(settings, worker_id )
188
190
"""
189
191
)
190
192
@@ -270,7 +272,7 @@ def test_sqlite_database_renamed(self, django_testdir):
270
272
from django.db import connections
271
273
272
274
@pytest.mark.django_db
273
- def test_a():
275
+ def test_a(worker_id ):
274
276
(conn_db2, conn_default) = sorted(
275
277
connections.all(),
276
278
key=lambda conn: conn.alias,
@@ -288,7 +290,7 @@ def test_a():
288
290
289
291
assert conn_db2.vendor == 'sqlite'
290
292
db_name = conn_db2.creation._get_test_db_name()
291
- assert db_name.startswith('test_custom_db_name_gw' )
293
+ assert db_name == 'test_custom_db_name_{}'.format(worker_id )
292
294
"""
293
295
)
294
296
@@ -377,13 +379,15 @@ def test_db_with_tox_suffix(self, django_testdir, monkeypatch):
377
379
from django.db import connections
378
380
379
381
@pytest.mark.django_db
380
- def test_inner():
382
+ def test_inner(worker_id ):
381
383
382
384
(conn, ) = connections.all()
383
385
384
386
assert conn.vendor == 'sqlite'
385
387
db_name = conn.creation._get_test_db_name()
386
- assert db_name.startswith('test_custom_db_name_py37-django22_gw')
388
+ assert db_name == 'test_custom_db_name_py37-django22_{}'.format(
389
+ worker_id,
390
+ )
387
391
"""
388
392
)
389
393
0 commit comments