-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconftest.py
46 lines (32 loc) · 938 Bytes
/
conftest.py
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
36
37
38
39
40
41
42
43
44
45
46
import os
import pytest
def pytest_addoption(parser):
parser.addoption("--db-uri", action="store")
def pytest_configure(config):
db_uri = config.getoption('db_uri')
if db_uri:
os.environ['CINCH_DB_URI'] = db_uri
# disable error catching for better traceback
from cinch import app
app.testing = True
@pytest.fixture
def session():
# importing at the module level messes up coverage
from cinch import db
def drop_and_recreate_db():
db.session.remove() # make sure we start with a new session
db.drop_all()
db.create_all()
drop_and_recreate_db()
return db.session
@pytest.yield_fixture
def app_context():
from cinch import app
with app.test_request_context():
yield app
@pytest.yield_fixture(autouse=True)
def temp_config():
from cinch import app
original_config = app.config.copy()
yield
app.config = original_config