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
@@ -1,7 +1,6 @@
|
||||
"""The tests the History component."""
|
||||
# pylint: disable=protected-access,too-many-public-methods
|
||||
from datetime import timedelta
|
||||
import os
|
||||
import unittest
|
||||
from unittest.mock import patch, sentinel
|
||||
|
||||
@@ -24,13 +23,10 @@ class TestComponentHistory(unittest.TestCase):
|
||||
"""Stop everything that was started."""
|
||||
self.hass.stop()
|
||||
|
||||
db_path = self.hass.config.path(recorder.DB_FILE)
|
||||
if os.path.isfile(db_path):
|
||||
os.remove(db_path)
|
||||
|
||||
def init_recorder(self):
|
||||
"""Initialize the recorder."""
|
||||
recorder.setup(self.hass, {})
|
||||
with patch('homeassistant.core.Config.path', return_value=':memory:'):
|
||||
recorder.setup(self.hass, {})
|
||||
self.hass.start()
|
||||
self.wait_recording_done()
|
||||
|
||||
|
||||
Reference in new issue
Block a user