@@ -159,32 +159,34 @@ def test_xdist_with_reuse(django_testdir):
159159
160160 from .app.models import Item
161161
162- def _check(settings):
162+ def _check(settings, worker_id ):
163163 # Make sure that the database name looks correct
164164 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+ )
167169 assert Item.objects.count() == 0
168170 Item.objects.create(name='foo')
169171 assert Item.objects.count() == 1
170172
171173
172174 @pytest.mark.django_db
173- def test_a(settings):
174- _check(settings)
175+ def test_a(settings, worker_id ):
176+ _check(settings, worker_id )
175177
176178
177179 @pytest.mark.django_db
178- def test_b(settings):
179- _check(settings)
180+ def test_b(settings, worker_id ):
181+ _check(settings, worker_id )
180182
181183 @pytest.mark.django_db
182- def test_c(settings):
183- _check(settings)
184+ def test_c(settings, worker_id ):
185+ _check(settings, worker_id )
184186
185187 @pytest.mark.django_db
186- def test_d(settings):
187- _check(settings)
188+ def test_d(settings, worker_id ):
189+ _check(settings, worker_id )
188190 """
189191 )
190192
@@ -270,7 +272,7 @@ def test_sqlite_database_renamed(self, django_testdir):
270272 from django.db import connections
271273
272274 @pytest.mark.django_db
273- def test_a():
275+ def test_a(worker_id ):
274276 (conn_db2, conn_default) = sorted(
275277 connections.all(),
276278 key=lambda conn: conn.alias,
@@ -288,7 +290,7 @@ def test_a():
288290
289291 assert conn_db2.vendor == 'sqlite'
290292 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 )
292294 """
293295 )
294296
@@ -377,13 +379,15 @@ def test_db_with_tox_suffix(self, django_testdir, monkeypatch):
377379 from django.db import connections
378380
379381 @pytest.mark.django_db
380- def test_inner():
382+ def test_inner(worker_id ):
381383
382384 (conn, ) = connections.all()
383385
384386 assert conn.vendor == 'sqlite'
385387 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+ )
387391 """
388392 )
389393
0 commit comments