summaryrefslogtreecommitdiffstats
path: root/tests/conftest.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 17:38:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 17:38:49 +0000
commit34de0b49d63d0539c5151f3001fb80db173cac9c (patch)
treec68cce344dc53b62c7f7ac5fa92c7dcfb6742c71 /tests/conftest.py
parentInitial commit. (diff)
downloadlitecli-34de0b49d63d0539c5151f3001fb80db173cac9c.tar.xz
litecli-34de0b49d63d0539c5151f3001fb80db173cac9c.zip
Adding upstream version 1.9.0.upstream/1.9.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/conftest.py')
-rw-r--r--tests/conftest.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
new file mode 100644
index 0000000..dce0d7e
--- /dev/null
+++ b/tests/conftest.py
@@ -0,0 +1,40 @@
+from __future__ import print_function
+
+import os
+import pytest
+from utils import create_db, db_connection, drop_tables
+import litecli.sqlexecute
+
+
+@pytest.yield_fixture(scope="function")
+def connection():
+ create_db("_test_db")
+ connection = db_connection("_test_db")
+ yield connection
+
+ drop_tables(connection)
+ connection.close()
+ os.remove("_test_db")
+
+
+@pytest.fixture
+def cursor(connection):
+ with connection.cursor() as cur:
+ return cur
+
+
+@pytest.fixture
+def executor(connection):
+ return litecli.sqlexecute.SQLExecute(database="_test_db")
+
+
+@pytest.fixture
+def exception_formatter():
+ return lambda e: str(e)
+
+
+@pytest.fixture(scope="session", autouse=True)
+def temp_config(tmpdir_factory):
+ # this function runs on start of test session.
+ # use temporary directory for config home so user config will not be used
+ os.environ["XDG_CONFIG_HOME"] = str(tmpdir_factory.mktemp("data"))