Skip to content

Commit ed892a6

Browse files
wip: fixing tests
1 parent 9d28979 commit ed892a6

File tree

1 file changed

+15
-28
lines changed

1 file changed

+15
-28
lines changed

tests/profiling/collector/test_asyncio.py

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,6 @@ def collector_class(self) -> CollectorType:
6666
def lock_class(self) -> LockType:
6767
raise NotImplementedError("Child classes must implement lock_class")
6868

69-
@property
70-
def lock_init_args(self) -> tuple:
71-
"""Arguments to pass to lock constructor. Override for Semaphore-like locks."""
72-
return ()
73-
74-
def create_lock(self) -> Union[asyncio.Lock, asyncio.Semaphore]:
75-
"""Create a lock instance with the appropriate arguments."""
76-
return self.lock_class(*self.lock_init_args)
77-
7869
def setup_method(self, method):
7970
self.test_name = method.__qualname__ if PY_311_OR_ABOVE else method.__name__
8071
self.output_prefix = "/tmp" + os.sep + self.test_name
@@ -99,14 +90,14 @@ def teardown_method(self):
9990
async def test_lock_events(self):
10091
"""Test basic acquire/release event profiling."""
10192
with self.collector_class(capture_pct=100):
102-
lock = self.create_lock() # !CREATE! test_lock_events
103-
await lock.acquire() # !ACQUIRE! test_lock_events
93+
lock = self.lock_class() # !CREATE! asyncio_test_lock_events
94+
await lock.acquire() # !ACQUIRE! asyncio_test_lock_events
10495
assert lock.locked()
105-
lock.release() # !RELEASE! test_lock_events
96+
lock.release() # !RELEASE! asyncio_test_lock_events
10697

10798
ddup.upload()
10899

109-
linenos = get_lock_linenos("test_lock_events")
100+
linenos = get_lock_linenos("asyncio_test_lock_events")
110101
profile = pprof_utils.parse_newest_profile(self.output_filename)
111102
expected_thread_id = _thread.get_ident()
112103
pprof_utils.assert_lock_events(
@@ -138,23 +129,23 @@ async def test_lock_events_tracer(self, tracer):
138129
span_type = ext.SpanTypes.WEB
139130

140131
with self.collector_class(capture_pct=100, tracer=tracer):
141-
lock = self.create_lock() # !CREATE! test_lock_events_tracer_1
142-
await lock.acquire() # !ACQUIRE! test_lock_events_tracer_1
132+
lock = self.lock_class() # !CREATE! asyncio_test_lock_events_tracer_1
133+
await lock.acquire() # !ACQUIRE! asyncio_test_lock_events_tracer_1
143134
with tracer.trace("test", resource=resource, span_type=span_type) as t:
144-
lock2 = self.create_lock() # !CREATE! test_lock_events_tracer_2
145-
await lock2.acquire() # !ACQUIRE! test_lock_events_tracer_2
146-
lock.release() # !RELEASE! test_lock_events_tracer_1
135+
lock2 = self.lock_class() # !CREATE! asyncio_test_lock_events_tracer_2
136+
await lock2.acquire() # !ACQUIRE! asyncio_test_lock_events_tracer_2
137+
lock.release() # !RELEASE! asyncio_test_lock_events_tracer_1
147138
span_id = t.span_id
148-
lock2.release() # !RELEASE! test_lock_events_tracer_2
139+
lock2.release() # !RELEASE! asyncio_test_lock_events_tracer_2
149140

150-
lock_ctx = self.create_lock() # !CREATE! test_lock_events_tracer_3
151-
async with lock_ctx: # !ACQUIRE! !RELEASE! test_lock_events_tracer_3
141+
lock_ctx = self.lock_class() # !CREATE! asyncio_test_lock_events_tracer_3
142+
async with lock_ctx: # !ACQUIRE! !RELEASE! asyncio_test_lock_events_tracer_3
152143
pass
153144
ddup.upload(tracer=tracer)
154145

155-
linenos_1 = get_lock_linenos("test_lock_events_tracer_1")
156-
linenos_2 = get_lock_linenos("test_lock_events_tracer_2")
157-
linenos_3 = get_lock_linenos("test_lock_events_tracer_3", with_stmt=True)
146+
linenos_1 = get_lock_linenos("asyncio_test_lock_events_tracer_1")
147+
linenos_2 = get_lock_linenos("asyncio_test_lock_events_tracer_2")
148+
linenos_3 = get_lock_linenos("asyncio_test_lock_events_tracer_3", with_stmt=True)
158149

159150
profile = pprof_utils.parse_newest_profile(self.output_filename)
160151
expected_thread_id = _thread.get_ident()
@@ -238,7 +229,3 @@ def collector_class(self):
238229
@property
239230
def lock_class(self):
240231
return asyncio.Semaphore
241-
242-
@property
243-
def lock_init_args(self):
244-
return (2,) # Initial semaphore value

0 commit comments

Comments
 (0)