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
|
||||
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
|
||||
def client(app):
|
||||
return app.test_client()
|
||||
|
||||
|
||||
def login(client, username, password):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue