Skip to content

Commit 5ac8b58

Browse files
committed
Fix code for newer pytest_xdist and sqlalchemy
1 parent 1511505 commit 5ac8b58

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pytest_sqlalchemy.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ def engine(request, sqlalchemy_connect_url, app_config):
2828
raise RuntimeError("Can not establish a connection to the database")
2929

3030
# Put a suffix like _gw0, _gw1 etc on xdist processes
31-
xdist_suffix = getattr(request.config, 'slaveinput', {}).get('slaveid')
31+
xdist_suffix = getattr(request.config, 'workerinput', {}).get('workerid')
32+
print(xdist_suffix)
3233
if engine.url.database != ':memory:' and xdist_suffix is not None:
33-
engine.url.database = '{}_{}'.format(engine.url.database, xdist_suffix)
34-
engine = create_engine(engine.url) # override engine
34+
url = engine.url.set(database=f'{engine.url.database}_{xdist_suffix}')
35+
engine = create_engine(url) # override engine
3536

3637
def fin():
3738
print ("Disposing engine")

0 commit comments

Comments
 (0)