<s> import pytest <EOL> from alchemist import db <EOL> import flask <EOL> from wsgi_intercept import add_wsgi_intercept , remove_wsgi_intercept <EOL> from wsgi_intercept . requests_intercept import install , uninstall <EOL> HOST = '<STR_LIT:localhost>' <EOL> PORT = <NUM_LIT> <EOL> @ pytest . fixture ( autouse = True , scope = '<STR_LIT>' ) <EOL> def fixture_server ( request ) : <EOL> install ( ) <EOL> add_wsgi_intercept ( HOST , PORT , lambda : flask . current_app ) <EOL> def finalize ( ) : <EOL> remove_wsgi_intercept ( HOST , PORT ) <EOL> uninstall ( ) <EOL> request . addfinalizer ( finalize ) <EOL> @ pytest . fixture ( autouse = True , scope = '<STR_LIT>' ) <EOL> def fixture_database ( request ) : <EOL> db . clear ( database = True ) <EOL> db . init ( database = True ) <EOL> def finalizer ( ) : <EOL> db . session . rollback ( ) <EOL> db . clear ( database = True ) <EOL> request . addfinalizer ( finalizer ) <EOL> @ pytest . fixture ( autouse = True , scope = '<STR_LIT>' ) <EOL> def fixture_data ( request ) : <EOL> request . addfinalizer ( lambda : db . flush ( ) ) </s>
