attempt terrible hack make run in memory
(cherry picked from commit 357275c)
This commit is contained in:
@@ -11,7 +11,7 @@ from sqlalchemy.orm import sessionmaker
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
# Add root folder to python paths
|
||||
sys.path.append(os.path.realpath(os.path.join(script_dir, '..', '..')))
|
||||
|
||||
sys._called_from_test = True
|
||||
|
||||
# noinspection PyUnresolvedReferences,PyUnusedLocal
|
||||
@pytest.fixture
|
||||
@@ -93,30 +93,12 @@ def DBInMemory_test():
|
||||
@pytest.fixture
|
||||
def DBInMemory():
|
||||
print("Creating database in memory")
|
||||
from os.path import realpath, join, dirname, abspath
|
||||
|
||||
'''
|
||||
global saveddata_memory
|
||||
saveddata_memory = True
|
||||
'''
|
||||
|
||||
import eos.config
|
||||
eos.config.saveddata_connectionstring = 'sqlite:///:memory:'
|
||||
|
||||
import eos
|
||||
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
|
||||
print(eos.db.saveddata_engine)
|
||||
print(eos.db.gamedata_engine)
|
||||
|
||||
@@ -2,6 +2,8 @@ import sys
|
||||
from os.path import realpath, join, dirname, abspath
|
||||
|
||||
from logbook import Logger
|
||||
import os
|
||||
istravis = os.environ.get('TRAVIS') == 'true'
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
debug = False
|
||||
@@ -11,7 +13,11 @@ gamedata_version = ""
|
||||
gamedata_connectionstring = 'sqlite:///' + unicode(realpath(join(dirname(abspath(__file__)), "..", "eve.db")), sys.getfilesystemencoding())
|
||||
pyfalog.debug("Gamedata connection string: {0}", gamedata_connectionstring)
|
||||
|
||||
saveddata_connectionstring = 'sqlite:///' + unicode(realpath(join(dirname(abspath(__file__)), "..", "saveddata", "saveddata.db")), sys.getfilesystemencoding())
|
||||
if istravis is True or sys._called_from_test:
|
||||
# Running in Travis. Run saveddata database in memory.
|
||||
saveddata_connectionstring = 'sqlite:///:memory:'
|
||||
else:
|
||||
saveddata_connectionstring = 'sqlite:///' + unicode(realpath(join(dirname(abspath(__file__)), "..", "saveddata", "saveddata.db")), sys.getfilesystemencoding())
|
||||
|
||||
pyfalog.debug("Saveddata connection string: {0}", saveddata_connectionstring)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user