-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
App session does not rollback, so tests are not isolated #28
Comments
Did you manage to find a solution? I'm dealing with the same problem |
unfortunatly i did not find a solution, i tryed for a week, then posted this message as a bottle in the sea… The workaround i use for now is to set the |
@yobuntu Have you tried adding the Without that fixture, I don't know whether the plugin will wrap your test case in a transaction. |
i finaly managed to make it work ! so there was 2 main caveats:
so now that i compare what works and what doesn't , it seams the only diff is in the
where db is directly imported from the model (see the one which is mocked in setup.cfg more over i changed the BaseFactory class to
so i'm sure there are no side effect depending of a session.commit() is or is not in the tested code I hope this will be usefull to you also i autouse the db_session fixture with :
so i don't need to pass the db_session fixture in every test (but still i wonder if i have a full understanding of the problem) |
Hello, i'm struggling with sqlalchemy flask and pytest for years now, and i'm very happy to find your extension as i will maybe at least be able to run proper tests with this setting, but there must be something don't understand somewhere:
The rollback works, but only for the object inserted by the tests (in my case, the factoryboy factories).
when the object are inserted by the
pytest-flask.client
fixture are not rolled back, despite the db.session mocking (see the test after the post test).As i said before i spend lots of time and efforts in it but the sqlalchemy session mechanism is still a bit of voodoo art to me, so i may be doing something plain wrong.
conftest.py
setup.cfg
chores/model.py
test_chore.py
The text was updated successfully, but these errors were encountered: