summaryrefslogtreecommitdiff
path: root/tests/helpers/fixtures.py
diff options
context:
space:
mode:
authorlufte <javier@lufte.net>2021-07-09 01:10:36 -0300
committerlufte <javier@lufte.net>2021-07-09 01:10:36 -0300
commit0c7b746a4ebfda0c8446558a56514b349aabdf41 (patch)
tree3f4fdd1259496f7657e0722b5487b9598b6ca769 /tests/helpers/fixtures.py
parent9aa6a76471d2669cfd61a164ba0111b1bb31fca6 (diff)
downloadqutebrowser-0c7b746a4ebfda0c8446558a56514b349aabdf41.tar.gz
qutebrowser-0c7b746a4ebfda0c8446558a56514b349aabdf41.zip
Restore the sql fixture to close DBs after testing
Diffstat (limited to 'tests/helpers/fixtures.py')
-rw-r--r--tests/helpers/fixtures.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/helpers/fixtures.py b/tests/helpers/fixtures.py
index 3426e18b2..c09fbdc2c 100644
--- a/tests/helpers/fixtures.py
+++ b/tests/helpers/fixtures.py
@@ -673,13 +673,21 @@ def download_stub(win_registry, tmpdir, stubs):
@pytest.fixture
-def web_history(fake_save_manager, tmpdir, data_tmpdir, config_stub, stubs,
+def database(data_tmpdir, request):
+ """Create a Database object."""
+ name = request.node.get_closest_marker("db_name") or "history.db"
+ db = sql.Database(str(data_tmpdir / name))
+ yield db
+ db.close()
+
+
+@pytest.fixture
+def web_history(fake_save_manager, tmpdir, database, config_stub, stubs,
monkeypatch):
"""Create a WebHistory object."""
config_stub.val.completion.timestamp_format = '%Y-%m-%d'
config_stub.val.completion.web_history.max_items = -1
- db = sql.Database(str(data_tmpdir / 'history.db'))
- web_history = history.WebHistory(db, stubs.FakeHistoryProgress())
+ web_history = history.WebHistory(database, stubs.FakeHistoryProgress())
monkeypatch.setattr(history, 'web_history', web_history)
return web_history