{"id":24427,"library":"pytest-flask-sqlalchemy","title":"pytest-flask-sqlalchemy","description":"A pytest plugin that provides fixtures to preserve test isolation in Flask-SQLAlchemy by using database transactions. It simplifies testing Flask applications with SQLAlchemy by allowing tests to roll back changes automatically. Current version is 1.1.0, with a release cadence of irregular minor updates.","status":"active","version":"1.1.0","language":"python","source_language":"en","source_url":"https://github.com/jeancochrane/pytest-flask-sqlalchemy","tags":["pytest","flask","sqlalchemy","testing","plugin"],"install":[{"cmd":"pip install pytest-flask-sqlalchemy","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"Main plugin module; no common wrong import.","wrong":"","symbol":"pytest_flask_sqlalchemy","correct":"import pytest_flask_sqlalchemy"}],"quickstart":{"code":"import pytest\n\n@pytest.fixture\ndef app():\n    from myapp import create_app\n    app = create_app()\n    app.config['TESTING'] = True\n    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'\n    return app\n\n@pytest.fixture\ndef db(app):\n    from myapp import db\n    db.init_app(app)\n    with app.app_context():\n        db.create_all()\n    yield db\n    db.drop_all()\n\ndef test_something(db):\n    # db.session is managed by plugin\n    assert True","lang":"python","description":"Basic setup with custom app and db fixtures; plugin ensures transaction rollback after each test."},"warnings":[{"fix":"Update dependencies: pip install --upgrade flask-sqlalchemy sqlalchemy","message":"Requires Flask-SQLAlchemy >=2.5 and SQLAlchemy >=1.3; incompatible with SQLAlchemy <1.3 and Flask-SQLAlchemy <2.5.","severity":"breaking","affected_versions":"1.0.0-1.1.0"},{"fix":"Use Python 3.7 or later.","message":"Drop of Python 3.6 support in v1.1.0. Python 3.7+ required.","severity":"breaking","affected_versions":">=1.1.0"},{"fix":"Upgrade pytest to >=6.0.1.","message":"pytest <6.0.1 is no longer supported as of v1.1.0.","severity":"deprecated","affected_versions":">=1.1.0"},{"fix":"Use db.session.rollback() or rely on plugin auto-rollback. Avoid explicit commit in tests.","message":"The plugin uses a transaction boundary per test; do not manually call db.session.commit() without rolling back, else test isolation may break.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'1.1.0':41 'allow':31 'applic':27 'automat':37 'back':35 'cadenc':45 'chang':36 'current':38 'databas':21 'fixtur':10 'flask':3,17,26,51 'flask-sqlalchemi':16 'irregular':47 'isol':14 'minor':48 'plugin':7,54 'preserv':12 'provid':9 'pytest':2,6,50 'pytest-flask-sqlalchemi':1 'releas':44 'roll':34 'simplifi':24 'sqlalchemi':4,18,29,52 'test':13,25,32,53 'transact':22 'updat':49 'use':20 'version':39","created_at":"2026-05-01T08:13:01.498623+00:00","updated_at":"2026-05-01T08:13:01.498623+00:00","problems":[{"fix":"Use 'import pytest_flask_sqlalchemy' (the module itself provides fixtures).","cause":"Incorrect import path. Some users try to import from a submodule that doesn't exist.","error":"ImportError: cannot import name 'pytest_flask_sqlalchemy' from 'pytest_flask_sqlalchemy'"},{"fix":"Remove @pytest.mark.flask_sqlalchemy from tests; plugin works implicitly via conftest.","cause":"Plugin does not provide a mark; users mistakenly use a mark that doesn't exist.","error":"pytest.PytestUnknownMarkWarning: Unknown pytest.mark.flask_sqlalchemy - is this a typo?"},{"fix":"Fixtures are automatically available (e.g., 'db_session'), no need to import them explicitly.","cause":"Trying to access a non-existent class or fixture directly.","error":"AttributeError: module 'pytest_flask_sqlalchemy' has no attribute 'Fixtures'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.1.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/jeancochrane/pytest-flask-sqlalchemy","docs":null,"changelog":null,"pypi":"https://pypi.org/project/pytest-flask-sqlalchemy/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing","web-framework","database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-29","last_verified":"2026-06-29","next_check":"2026-07-29","install_tag":null}}