Skip to content

Commit ada2162

Browse files
committed
Fixed some tests
1 parent 3ef6cbb commit ada2162

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

tests/integrations/sqlalchemy/test_sqlalchemy.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import contextlib
12
import os
23
from datetime import datetime
34
from unittest import mock
@@ -619,21 +620,15 @@ class Person(Base):
619620
bob = Person(name="Bob")
620621
session.add(bob)
621622

622-
class fake_record_sql_queries: # noqa: N801
623-
def __init__(self, *args, **kwargs):
624-
with freeze_time(datetime(2024, 1, 1, microsecond=0)):
625-
with record_sql_queries(*args, **kwargs) as span:
626-
self.span = span
627-
freezer = freeze_time(datetime(2024, 1, 1, microsecond=99999))
628-
freezer.start()
623+
@contextlib.contextmanager
624+
def fake_record_sql_queries(*args, **kwargs): # noqa: N801
625+
with freeze_time(datetime(2024, 1, 1, second=0)):
626+
with record_sql_queries(*args, **kwargs) as span:
627+
freezer = freeze_time(datetime(2024, 1, 1, second=1))
628+
freezer.start()
629+
yield span
629630

630-
freezer.stop()
631-
632-
def __enter__(self):
633-
return self.span
634-
635-
def __exit__(self, type, value, traceback):
636-
pass
631+
freezer.stop()
637632

638633
with mock.patch(
639634
"sentry_sdk.integrations.sqlalchemy.record_sql_queries",

0 commit comments

Comments
 (0)