<s> import pytest <EOL> import pprint <EOL> from . . helpers . movie_data import Movie , Actor , Director , Document <EOL> from . fixtures import backend <EOL> from sqlalchemy . exc import IntegrityError <EOL> from blitzdb . fields import EnumField <EOL> def test_implicit_transaction ( backend ) : <EOL> backend . init_schema ( ) <EOL> backend . create_schema ( ) <EOL> al_pacino = Actor ( { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:action>' } ) <EOL> backend . save ( al_pacino ) <EOL> assert backend . current_transaction <EOL> assert backend . _conn is not None <EOL> backend . commit ( ) <EOL> assert backend . current_transaction is None <EOL> assert backend . _conn is None <EOL> def test_explicit_transaction ( backend ) : <EOL> backend . init_schema ( ) <EOL> backend . create_schema ( ) <EOL> al_pacino = Actor ( { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:action>' } ) <EOL> transaction = backend . begin ( ) <EOL> backend . save ( al_pacino ) <EOL> assert backend . current_transaction == transaction <EOL> assert backend . _conn is not None <EOL> backend . commit ( ) <EOL> assert backend . current_transaction is None <EOL> assert backend . _conn is None </s>
