Commit 1a093d76 authored by Julien Muchembled's avatar Julien Muchembled

qa: speed up SQlite tests by accessing DBs in unsafe mode (e.g. no sync)

parent fbcf9c50
......@@ -402,6 +402,8 @@ Environment Variables:
return runner.buildReport(self.add_status)
def main(args=None):
from neo.storage.database.manager import DatabaseManager
DatabaseManager.UNSAFE = True
runner = TestRunner()
runner.run()
return sys.exit(not runner.was_successful())
......
......@@ -53,6 +53,7 @@ class DatabaseManager(object):
"""This class only describes an interface for database managers."""
ENGINES = ()
UNSAFE = False
_deferred = 0
_duplicating = _repairing = None
......
......@@ -78,6 +78,10 @@ class SQLiteDatabaseManager(DatabaseManager):
def _connect(self):
logging.info('connecting to SQLite database %r', self.db)
self.conn = sqlite3.connect(self.db, check_same_thread=False)
if self.UNSAFE:
q = self.query
q("PRAGMA synchronous = OFF")
q("PRAGMA journal_mode = MEMORY")
self._config = {}
def _commit(self):
......@@ -108,6 +112,10 @@ class SQLiteDatabaseManager(DatabaseManager):
raise
def _setup(self):
# SQLite does support transactional Data Definition Language statements
# but unfortunately, the built-in Python binding automatically commits
# between such statements. This anti-feature causes this method to be
# relatively slow; unit tests enables the UNSAFE boolean flag.
self._config.clear()
q = self.query
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment