|
|
|
@ -17,33 +17,25 @@ from flaskr.blueprints.flaskr import init_db
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture |
|
|
|
|
def app(request): |
|
|
|
|
|
|
|
|
|
db_fd, temp_db_location = tempfile.mkstemp() |
|
|
|
|
def app(): |
|
|
|
|
db_fd, db_path = tempfile.mkstemp() |
|
|
|
|
config = { |
|
|
|
|
'DATABASE': temp_db_location, |
|
|
|
|
'DATABASE': db_path, |
|
|
|
|
'TESTING': True, |
|
|
|
|
'DB_FD': db_fd |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
app = create_app(config=config) |
|
|
|
|
|
|
|
|
|
with app.app_context(): |
|
|
|
|
init_db() |
|
|
|
|
yield app |
|
|
|
|
|
|
|
|
|
os.close(db_fd) |
|
|
|
|
os.unlink(db_path) |
|
|
|
|
|
|
|
|
|
@pytest.fixture |
|
|
|
|
def client(request, app): |
|
|
|
|
|
|
|
|
|
client = app.test_client() |
|
|
|
|
|
|
|
|
|
def teardown(): |
|
|
|
|
os.close(app.config['DB_FD']) |
|
|
|
|
os.unlink(app.config['DATABASE']) |
|
|
|
|
request.addfinalizer(teardown) |
|
|
|
|
|
|
|
|
|
return client |
|
|
|
|
@pytest.fixture |
|
|
|
|
def client(app): |
|
|
|
|
return app.test_client() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def login(client, username, password): |
|
|
|
|