-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconftest.py
More file actions
35 lines (23 loc) · 838 Bytes
/
conftest.py
File metadata and controls
35 lines (23 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import string
import os
import pytest
import datetime
from psycopg2 import connect
from psycopg2.extensions import connection as Connection
from tests.utils import RandomTablenameGenerator
@pytest.fixture
def postgres_connection():
connection: Connection
with connect(dbname="postgres", user="postgres", port=5432, host="localhost", password="postgres") as connection:
yield connection
@pytest.fixture
def random_tablename():
yield RandomTablenameGenerator(string.ascii_lowercase, 16)
@pytest.fixture(autouse=True, scope="session")
def test_run_start_time():
test_start_time = set_test_start_time()
return test_start_time
def set_test_start_time():
return datetime.datetime.today().strftime("%Y-%m-%dT%H-%M")
def pytest_sessionstart(session):
os.mkdir("./results/" + set_test_start_time())