Spaces:
Sleeping
Sleeping
chores
Browse files- tests/conftest.py +18 -0
tests/conftest.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
import sqlite3
|
| 3 |
+
|
| 4 |
+
from blossomtune_gradio import database
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
@pytest.fixture
|
| 8 |
+
def in_memory_db(mocker):
|
| 9 |
+
"""
|
| 10 |
+
Fixture to set up and tear down an in-memory SQLite database for tests.
|
| 11 |
+
It ensures that the same connection object is used for both schema
|
| 12 |
+
initialization and the test execution.
|
| 13 |
+
"""
|
| 14 |
+
con = sqlite3.connect(":memory:")
|
| 15 |
+
mocker.patch("sqlite3.connect", return_value=con)
|
| 16 |
+
database.init()
|
| 17 |
+
yield con
|
| 18 |
+
con.close()
|