Master programming syntax, solve interactive challenges & run live code in Syntaxis Explore Arena →
menu_book Course Curriculum (Software Testing) expand_more
Software Testing / Test Doubles & Dependencies

database transaction rollback tests

Learn database transaction rollback tests in Software Testing with a dedicated explanation, a concept-specific example, practical cautions, and a mastery check.

12 min read • Intermediate
software-testing-024.py
python
def test_create_order(db):
    db.begin()
    try:
        db.execute('insert into orders(id,total) values(1,99)')
        assert db.scalar('select count(*) from orders') == 1
    finally:
        db.rollback()
What to watch
Content source & attribution
Original Syntaxis Content · Original Syntaxis Content