@@ -43,13 +43,15 @@ def test_duplicated_uninstrumentation(self):
43
43
def test_cursor_instrumentation (self ):
44
44
def assert_wrapped (assert_fnc ):
45
45
for cls , methods in [
46
- (cursor .Cursor , ("forward" , "fetch" , "fetchrow" )),
47
- (cursor .CursorIterator , ("__anext__" , ))
46
+ (cursor .Cursor , ("forward" , "fetch" , "fetchrow" )),
47
+ (cursor .CursorIterator , ("__anext__" ,)),
48
48
]:
49
49
for method_name in methods :
50
50
method = getattr (cls , method_name , None )
51
- assert_fnc (isinstance (method , ObjectProxy ), f"{ method } isinstance { type (method )} " )
52
-
51
+ assert_fnc (
52
+ isinstance (method , ObjectProxy ),
53
+ f"{ method } isinstance { type (method )} " ,
54
+ )
53
55
54
56
assert_wrapped (self .assertFalse )
55
57
AsyncPGInstrumentor ().instrument ()
@@ -58,8 +60,8 @@ def assert_wrapped(assert_fnc):
58
60
assert_wrapped (self .assertFalse )
59
61
60
62
def test_cursor_span_creation (self ):
61
- """ Test the cursor wrapper if it creates spans correctly.
62
- """
63
+ """Test the cursor wrapper if it creates spans correctly."""
64
+
63
65
# Mock out all interaction with postgres
64
66
async def bind_mock (* args , ** kwargs ):
65
67
return []
@@ -84,7 +86,7 @@ async def exec_mock(*args, **kwargs):
84
86
85
87
# init the cursor and fetch a single record
86
88
crs = cursor .Cursor (conn , "SELECT * FROM test" , state , [], Record )
87
- asyncio .run (crs ._init (1 ))
89
+ asyncio .run (crs ._init (1 ))
88
90
asyncio .run (crs .fetch (1 ))
89
91
90
92
spans = self .memory_exporter .get_finished_spans ()
@@ -93,11 +95,13 @@ async def exec_mock(*args, **kwargs):
93
95
self .assertTrue (spans [0 ].status .is_ok )
94
96
95
97
# Now test that the StopAsyncIteration of the cursor does not get recorded as an ERROR
96
- crs_iter = cursor .CursorIterator (conn , "SELECT * FROM test" , state , [], Record , 1 , 1 )
98
+ crs_iter = cursor .CursorIterator (
99
+ conn , "SELECT * FROM test" , state , [], Record , 1 , 1
100
+ )
97
101
98
102
with pytest .raises (StopAsyncIteration ):
99
103
asyncio .run (crs_iter .__anext__ ())
100
104
101
105
spans = self .memory_exporter .get_finished_spans ()
102
106
self .assertEqual (len (spans ), 2 )
103
- self .assertEqual ([span .status .is_ok for span in spans ], [True , True ])
107
+ self .assertEqual ([span .status .is_ok for span in spans ], [True , True ])
0 commit comments