From ce86c1e3a1080ed574e136fe5cd525af072cc12b Mon Sep 17 00:00:00 2001 From: tammy-baylis-swi Date: Wed, 20 Nov 2024 11:37:28 -0800 Subject: [PATCH] Adjust tests --- .../tests/test_dbapi_integration.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-dbapi/tests/test_dbapi_integration.py b/instrumentation/opentelemetry-instrumentation-dbapi/tests/test_dbapi_integration.py index 1236750ec7..2ffa2f3d5b 100644 --- a/instrumentation/opentelemetry-instrumentation-dbapi/tests/test_dbapi_integration.py +++ b/instrumentation/opentelemetry-instrumentation-dbapi/tests/test_dbapi_integration.py @@ -594,10 +594,7 @@ def test_instrument_connection(self): @mock.patch("opentelemetry.instrumentation.dbapi.DatabaseApiIntegration") def test_instrument_connection_kwargs_defaults(self, mock_dbapiint): - connection = mock.Mock() - # Avoid get_attributes failing because can't concatenate mock - connection.database = "-" - dbapi.instrument_connection(self.tracer, connection, "-") + dbapi.instrument_connection(self.tracer, mock.Mock(), "foo") kwargs = mock_dbapiint.call_args[1] self.assertEqual(kwargs["connection_attributes"], None) self.assertEqual(kwargs["version"], "") @@ -611,13 +608,10 @@ def test_instrument_connection_kwargs_defaults(self, mock_dbapiint): def test_instrument_connection_kwargs_provided(self, mock_dbapiint): mock_tracer_provider = mock.MagicMock() mock_connect_module = mock.MagicMock() - connection = mock.Mock() - # Avoid get_attributes failing because can't concatenate mock - connection.database = "-" dbapi.instrument_connection( self.tracer, - connection, - "-", + mock.Mock(), + "foo", connection_attributes={"foo": "bar"}, version="test", tracer_provider=mock_tracer_provider, @@ -629,11 +623,11 @@ def test_instrument_connection_kwargs_provided(self, mock_dbapiint): kwargs = mock_dbapiint.call_args[1] self.assertEqual(kwargs["connection_attributes"], {"foo": "bar"}) self.assertEqual(kwargs["version"], "test") - self.assertEqual(kwargs["tracer_provider"], mock_tracer_provider) + self.assertIs(kwargs["tracer_provider"], mock_tracer_provider) self.assertEqual(kwargs["capture_parameters"], True) self.assertEqual(kwargs["enable_commenter"], True) self.assertEqual(kwargs["commenter_options"], {"foo": "bar"}) - self.assertEqual(kwargs["connect_module"], mock_connect_module) + self.assertIs(kwargs["connect_module"], mock_connect_module) def test_uninstrument_connection(self): connection = mock.Mock()