recreate DB connection
(cherry picked from commit 5593e28)
This commit is contained in:
@@ -4,6 +4,9 @@ import pytest
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from sqlalchemy import MetaData, create_engine
|
||||||
|
from sqlalchemy.orm import sessionmaker
|
||||||
|
|
||||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
# Add root folder to python paths
|
# Add root folder to python paths
|
||||||
sys.path.append(os.path.realpath(os.path.join(script_dir, '..', '..')))
|
sys.path.append(os.path.realpath(os.path.join(script_dir, '..', '..')))
|
||||||
@@ -27,6 +30,17 @@ def DBInMemory():
|
|||||||
import eos
|
import eos
|
||||||
import eos.db
|
import eos.db
|
||||||
|
|
||||||
|
# Replace the existing DB connection with our own. For some reason on Linux, it ignores what we set above. :(
|
||||||
|
if callable('sqlite:///:memory:'):
|
||||||
|
eos.db.saveddata_engine = create_engine(creator='sqlite:///:memory:', echo=eos.config.debug)
|
||||||
|
else:
|
||||||
|
eos.db.saveddata_engine = create_engine('sqlite:///:memory:', echo=eos.config.debug)
|
||||||
|
|
||||||
|
eos.db.saveddata_meta = MetaData()
|
||||||
|
eos.db.saveddata_meta.bind = eos.db.saveddata_engine
|
||||||
|
eos.db.saveddata_session = sessionmaker(bind=eos.db.saveddata_engine, autoflush=False, expire_on_commit=False)()
|
||||||
|
eos.db.saveddata_meta.create_all()
|
||||||
|
|
||||||
# Output debug info to help us troubleshoot Travis
|
# Output debug info to help us troubleshoot Travis
|
||||||
print(eos.db.saveddata_engine)
|
print(eos.db.saveddata_engine)
|
||||||
print(eos.db.gamedata_engine)
|
print(eos.db.gamedata_engine)
|
||||||
|
|||||||
@@ -54,8 +54,6 @@ except Exception as e:
|
|||||||
pyfalog.critical(e)
|
pyfalog.critical(e)
|
||||||
config.gamedata_version = None
|
config.gamedata_version = None
|
||||||
|
|
||||||
print("Test: " + config.saveddata_connectionstring)
|
|
||||||
|
|
||||||
saveddata_connectionstring = config.saveddata_connectionstring
|
saveddata_connectionstring = config.saveddata_connectionstring
|
||||||
if saveddata_connectionstring is not None:
|
if saveddata_connectionstring is not None:
|
||||||
if callable(saveddata_connectionstring):
|
if callable(saveddata_connectionstring):
|
||||||
|
|||||||
Reference in New Issue
Block a user