Browse Source

fix windows failure to remove temp file

pull/2558/head
David Lord 7 years ago
parent
commit
ffca68fc86
No known key found for this signature in database
GPG Key ID: 7A1C87E3F5BC42A8
  1. 24
      examples/flaskr/tests/test_flaskr.py

24
examples/flaskr/tests/test_flaskr.py

@ -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):

Loading…
Cancel
Save