Make tox run faster by using in-memory sqlite db. (#1752)
Two tests were invariably grinding my system to a halt as it was applying migrations to an empty sqlite database. This patch reduces the time of a pytest run from 50 to about 16 seconds on my desktop. The difference is even more noticable on a slower laptop drive, but is probably insignificant for all you fancy SSD users.
This commit is contained in:
1 parent
f5227e1de0
commit
c481cbce7e
3 files changed
+8
-11
No files matched your search
@@ -168,6 +168,7 @@ class RecorderRun(object):
|
||||
class Recorder(threading.Thread):
|
||||
"""A threaded recorder class."""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
def __init__(self, hass):
|
||||
"""Initialize the recorder."""
|
||||
threading.Thread.__init__(self)
|
||||
@@ -179,6 +180,7 @@ class Recorder(threading.Thread):
|
||||
self.lock = threading.Lock()
|
||||
self.recording_start = dt_util.utcnow()
|
||||
self.utc_offset = dt_util.now().utcoffset().total_seconds()
|
||||
self.db_path = self.hass.config.path(DB_FILE)
|
||||
|
||||
def start_recording(event):
|
||||
"""Start recording."""
|
||||
@@ -302,8 +304,7 @@ class Recorder(threading.Thread):
|
||||
|
||||
def _setup_connection(self):
|
||||
"""Ensure database is ready to fly."""
|
||||
db_path = self.hass.config.path(DB_FILE)
|
||||
self.conn = sqlite3.connect(db_path, check_same_thread=False)
|
||||
self.conn = sqlite3.connect(self.db_path, check_same_thread=False)
|
||||
self.conn.row_factory = sqlite3.Row
|
||||
|
||||
# Make sure the database is closed whenever Python exits
|
||||
|
||||
Reference in new issue
Block a user