Skip to content

Isolation in tests via join_transaction_mode #8

@krylosov-aa

Description

@krylosov-aa

Perhaps more tests can be written using transaction rollback rather than manual data cleanup.

We can take this example: https://docs.sqlalchemy.org/en/20/orm/session_transaction.html#joining-a-session-into-an-external-transaction-such-as-for-test-suites

The idea: in conftest, a session is created as it is now. But instead of adding it to the context, you can create a new session with join_transaction_mode="create_savepoint." This way, the application will be able to commit the transaction, but will actually be working on the save point.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions