forked from orbit-oss/flask
fix windows failure to remove temp file
This commit is contained in:
parent
3012d20a3f
commit
ffca68fc86
1 changed files with 8 additions and 16 deletions
|
|
@ -17,33 +17,25 @@ from flaskr.blueprints.flaskr import init_db
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def app(request):
|
def app():
|
||||||
|
db_fd, db_path = tempfile.mkstemp()
|
||||||
db_fd, temp_db_location = tempfile.mkstemp()
|
|
||||||
config = {
|
config = {
|
||||||
'DATABASE': temp_db_location,
|
'DATABASE': db_path,
|
||||||
'TESTING': True,
|
'TESTING': True,
|
||||||
'DB_FD': db_fd
|
|
||||||
}
|
}
|
||||||
|
|
||||||
app = create_app(config=config)
|
app = create_app(config=config)
|
||||||
|
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
init_db()
|
init_db()
|
||||||
yield app
|
yield app
|
||||||
|
|
||||||
|
os.close(db_fd)
|
||||||
|
os.unlink(db_path)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def client(request, app):
|
def client(app):
|
||||||
|
return app.test_client()
|
||||||
client = app.test_client()
|
|
||||||
|
|
||||||
def teardown():
|
|
||||||
os.close(app.config['DB_FD'])
|
|
||||||
os.unlink(app.config['DATABASE'])
|
|
||||||
request.addfinalizer(teardown)
|
|
||||||
|
|
||||||
return client
|
|
||||||
|
|
||||||
|
|
||||||
def login(client, username, password):
|
def login(client, username, password):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue