forked from tecladocode/testing-python-apps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase_test.py
More file actions
33 lines (26 loc) · 826 Bytes
/
Copy pathbase_test.py
File metadata and controls
33 lines (26 loc) · 826 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
"""
BaseTest
This class should be the parent class to each unit test.
It allows for instantiation of the database dynamically,
and makes sure that it is a new, blank database each time.
"""
from unittest import TestCase
from app import app
from db import db
class BaseTest(TestCase):
SQLALCHEMY_DATABASE_URI = "sqlite://"
@classmethod
def setUpClass(cls):
app.config['SQLALCHEMY_DATABASE_URI'] = BaseTest.SQLALCHEMY_DATABASE_URI
app.config['DEBUG'] = False
with app.app_context():
db.init_app(app)
def setUp(self):
with app.app_context():
db.create_all()
self.app = app.test_client
self.app_context = app.app_context
def tearDown(self):
with app.app_context():
db.session.remove()
db.drop_all()