-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
44 lines (27 loc) · 823 Bytes
/
conftest.py
File metadata and controls
44 lines (27 loc) · 823 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
36
37
38
39
40
41
42
43
44
import os
import pytest
from core import create_app
from setup import run_setup
class TestAppInitializer:
__app = None
@property
def app(self):
if self.__app is not None:
return self.__app
self.__app = create_app("TestingConfig")
self.__app.app_context().push()
return self.__app
test_app_initializer = TestAppInitializer()
def test_app():
return test_app_initializer.app
@pytest.fixture(scope="session", autouse=True)
def setup_and_teardown():
test_app_instance = test_app_initializer.app
database_file = test_app_instance.config["SQLALCHEMY_DATABASE_URI"].replace(
"sqlite://", ""
)
if os.path.exists(database_file):
os.remove(database_file)
run_setup("TestingConfig")
yield
os.remove(database_file)