Skip to content
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

Remove transaction.rollback() and use session fixture #1117

Merged
merged 10 commits into from
Jul 29, 2024
Next Next commit
Update conftest.py
  • Loading branch information
michplunkett committed Jul 24, 2024
commit f5da031ef0a7fa0cd9e484c63034fff8abf49bf0
11 changes: 6 additions & 5 deletions OpenOversight/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,12 @@ def session(db):
session = scoped_session(session_factory=sessionmaker(bind=connection))
db.session = session

yield session

transaction.rollback()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The transaction.rollback() function call here was redundant. SQLAlchemy was already taking care of it for any of the tests that needed it (i.e., test__uuid_uniqueness_constraint, test_redirect_add_salary, test_add_department__duplicate).

connection.close()
session.remove()
try:
yield session
finally:
session.remove()
transaction.rollback()
connection.close()


@pytest.fixture
Expand Down