#NEWLINE# @ pytest . fixture ( autouse = True ) #NEWLINE# def database_session( request , monkeypatch ) : #NEWLINE# #INDENT# '\n    Prepare the SQLAlchemy session object.\n\n    We enable fast repeatable database tests by setting up the database only\n    once per session (see :func:`setup_database`) and then wrapping each test\n    function in a SAVEPOINT/ROLLBACK TO SAVEPOINT within the transaction.\n    ' #NEWLINE# db . Session . begin_nested ( ) #NEWLINE# request . addfinalizer ( db . Session . rollback ) #NEWLINE# def _fake_commit( ) : #NEWLINE# #INDENT# db . Session . flush ( ) #NEWLINE# db . Session . expire_all ( ) #NEWLINE# #UNINDENT# monkeypatch . setattr ( db . Session , 'commit' , _fake_commit ) #NEWLINE# monkeypatch . setattr ( db . Session , 'remove' , ( lambda : None ) )