<s> import pytest <EOL> from sqlalchemy . orm import scoped_session , sessionmaker <EOL> from webapp import db , create_app <EOL> from webapp . settings import TestConfig <EOL> @ pytest . yield_fixture ( scope = "<STR_LIT>" ) <EOL> def app ( ) : <EOL> _app = create_app ( TestConfig ) <EOL> db . app = _app <EOL> db . create_all ( ) <EOL> _app . connection = db . engine . connect ( ) <EOL> yield _app <EOL> _app . connection . close ( ) <EOL> db . drop_all ( ) <EOL> @ pytest . yield_fixture ( scope = "<STR_LIT>" ) <EOL> def session ( app ) : <EOL> app . transaction = app . connection . begin ( ) <EOL> with app . app_context ( ) : <EOL> session = scoped_session ( sessionmaker ( bind = app . connection ) ) <EOL> db . session = session <EOL> yield session <EOL> app . transaction . rollback ( ) <EOL> session . remove ( ) <EOL> @ pytest . fixture ( scope = "<STR_LIT>" ) <EOL> def client ( app ) : <EOL> return app . test_client ( ) </s>
