@@ -262,14 +262,14 @@ def test_callproc(self):
262262
263263 @mock .patch ("opentelemetry.instrumentation.dbapi" )
264264 def test_wrap_connect (self , mock_dbapi ):
265- dbapi .wrap_connect (self .tracer , mock_dbapi , "connect" , "-" )
265+ dbapi .wrap_connect (self .tracer , MockConnectionEmpty () , "connect" , "-" )
266266 connection = mock_dbapi .connect ()
267267 self .assertEqual (mock_dbapi .connect .call_count , 1 )
268- self .assertIsInstance (connection .__wrapped__ , mock .Mock )
268+ self .assertIsInstance (connection ._connection , mock .Mock )
269269
270270 @mock .patch ("opentelemetry.instrumentation.dbapi" )
271271 def test_unwrap_connect (self , mock_dbapi ):
272- dbapi .wrap_connect (self .tracer , mock_dbapi , "connect" , "-" )
272+ dbapi .wrap_connect (self .tracer , MockConnectionEmpty () , "connect" , "-" )
273273 connection = mock_dbapi .connect ()
274274 self .assertEqual (mock_dbapi .connect .call_count , 1 )
275275
@@ -279,19 +279,19 @@ def test_unwrap_connect(self, mock_dbapi):
279279 self .assertIsInstance (connection , mock .Mock )
280280
281281 def test_instrument_connection (self ):
282- connection = mock . Mock ()
282+ connection = MockConnectionEmpty ()
283283 # Avoid get_attributes failing because can't concatenate mock
284284 connection .database = "-"
285285 connection2 = dbapi .instrument_connection (self .tracer , connection , "-" )
286- self .assertIs (connection2 .__wrapped__ , connection )
286+ self .assertIs (connection2 ._connection , connection )
287287
288288 def test_uninstrument_connection (self ):
289- connection = mock . Mock ()
289+ connection = MockConnectionEmpty ()
290290 # Set connection.database to avoid a failure because mock can't
291291 # be concatenated
292292 connection .database = "-"
293293 connection2 = dbapi .instrument_connection (self .tracer , connection , "-" )
294- self .assertIs (connection2 .__wrapped__ , connection )
294+ self .assertIs (connection2 ._connection , connection )
295295
296296 connection3 = dbapi .uninstrument_connection (connection2 )
297297 self .assertIs (connection3 , connection )
@@ -307,10 +307,12 @@ def mock_connect(*args, **kwargs):
307307 server_host = kwargs .get ("server_host" )
308308 server_port = kwargs .get ("server_port" )
309309 user = kwargs .get ("user" )
310- return MockConnection (database , server_port , server_host , user )
310+ return MockConnectionWithAttributes (
311+ database , server_port , server_host , user
312+ )
311313
312314
313- class MockConnection :
315+ class MockConnectionWithAttributes :
314316 def __init__ (self , database , server_port , server_host , user ):
315317 self .database = database
316318 self .server_port = server_port
@@ -343,3 +345,7 @@ def executemany(self, query, params=None, throw_exception=False):
343345 def callproc (self , query , params = None , throw_exception = False ):
344346 if throw_exception :
345347 raise Exception ("Test Exception" )
348+
349+
350+ class MockConnectionEmpty :
351+ pass
0 commit comments