Skip to content

Commit

Permalink
cassandra: fix tests for py313 (#3152)
Browse files Browse the repository at this point in the history
* cassandra: fix tests to make CI happy for py313

Signed-off-by: emdneto <[email protected]>

* ruff

Signed-off-by: emdneto <[email protected]>

---------

Signed-off-by: emdneto <[email protected]>
  • Loading branch information
emdneto authored Dec 24, 2024
1 parent d116ae3 commit 16eaec8
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def tearDown(self):
with self.disable_logging():
CassandraInstrumentor().uninstrument()

@property
def _mocked_session(self):
return cassandra.cluster.Session(cluster=mock.Mock(), hosts=[])

def test_instrument_uninstrument(self):
instrumentation = CassandraInstrumentor()
instrumentation.instrument()
Expand All @@ -67,7 +71,7 @@ def test_instrumentor(
):
mock_create_response_future.return_value = mock.Mock()
mock_session_init.return_value = None
mock_connect.return_value = cassandra.cluster.Session()
mock_connect.return_value = self._mocked_session

CassandraInstrumentor().instrument()

Expand Down Expand Up @@ -100,7 +104,7 @@ def test_custom_tracer_provider(
):
mock_create_response_future.return_value = mock.Mock()
mock_session_init.return_value = None
mock_connect.return_value = cassandra.cluster.Session()
mock_connect.return_value = self._mocked_session

resource = resources.Resource.create({})
result = self.create_tracer_provider(resource=resource)
Expand All @@ -124,7 +128,7 @@ def test_instrument_connection_no_op_tracer_provider(
):
mock_create_response_future.return_value = mock.Mock()
mock_session_init.return_value = None
mock_connect.return_value = cassandra.cluster.Session()
mock_connect.return_value = self._mocked_session

tracer_provider = trace_api.NoOpTracerProvider()
CassandraInstrumentor().instrument(tracer_provider=tracer_provider)
Expand Down

0 comments on commit 16eaec8

Please sign in to comment.