summaryrefslogtreecommitdiffstats
path: root/tests/conftest.py
diff options
context:
space:
mode:
authorKarl-Aksel Puulmann <oxymaccy@gmail.com>2015-01-07 23:30:20 +0200
committerAmjith Ramanujam <amjith.r@gmail.com>2015-01-09 00:13:19 -0800
commita87f3a1fcc11abe0cc40ebbc6eee23d4e89604b5 (patch)
tree53a61a6c934fb837c19987ce6feed2ed65cd7ebd /tests/conftest.py
parent0cec2cfa1c3fafc5bc0125d52ac98fbb73263672 (diff)
Checking if database exists and some initial fixtures which clean up
Diffstat (limited to 'tests/conftest.py')
-rw-r--r--tests/conftest.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
new file mode 100644
index 00000000..2f45e2a5
--- /dev/null
+++ b/tests/conftest.py
@@ -0,0 +1,24 @@
+import pytest
+from utils import *
+from pgcli.pgexecute import PGExecute
+
+
+@pytest.yield_fixture(scope="function")
+def connection():
+ create_db('_test_db')
+ connection = db_connection('_test_db')
+ yield connection
+
+ drop_tables(connection)
+ connection.close()
+
+
+@pytest.fixture
+def cursor(connection):
+ with connection.cursor() as cur:
+ return cur
+
+
+@pytest.fixture
+def executor(connection):
+ return PGExecute(database='_test_db', user=POSTGRES_USER, host=POSTGRES_HOST)