|
3 | 3 | import glob |
4 | 4 | import os |
5 | 5 | import sys |
| 6 | +from typing import Optional |
6 | 7 | import uuid |
7 | 8 |
|
8 | 9 | import pytest |
9 | 10 |
|
10 | 11 | from ddtrace import ext |
11 | 12 | from ddtrace.internal.datadog.profiling import ddup |
12 | 13 | from ddtrace.profiling.collector import asyncio as collector_asyncio |
| 14 | +from ddtrace.profiling.collector._lock import _LockAllocatorWrapper as LockAllocatorWrapper |
13 | 15 | from tests.profiling.collector import pprof_utils |
14 | 16 | from tests.profiling.collector import test_collector |
15 | 17 | from tests.profiling.collector.lock_utils import get_lock_linenos |
@@ -53,28 +55,18 @@ def teardown_method(self): |
53 | 55 |
|
54 | 56 | async def test_subclassing_wrapped_lock(self) -> None: |
55 | 57 | """Test that subclassing of a wrapped lock type when profiling is active.""" |
56 | | - from typing import Optional |
57 | | - |
58 | | - from ddtrace.profiling.collector._lock import _LockAllocatorWrapper |
59 | | - |
60 | 58 | with collector_asyncio.AsyncioLockCollector(capture_pct=100): |
61 | | - assert isinstance(asyncio.Lock, _LockAllocatorWrapper) |
| 59 | + assert isinstance(asyncio.Lock, LockAllocatorWrapper) |
62 | 60 |
|
63 | 61 | # This should NOT raise TypeError |
64 | 62 | class CustomLock(asyncio.Lock): # type: ignore[misc] |
65 | 63 | def __init__(self) -> None: |
66 | 64 | super().__init__() |
67 | | - self._owner: Optional[int] = None |
68 | | - self._count: int = 0 |
69 | 65 |
|
70 | 66 | # Verify subclassing and functionality |
71 | 67 | custom_lock: CustomLock = CustomLock() |
72 | | - assert hasattr(custom_lock, "_owner") |
73 | | - assert hasattr(custom_lock, "_count") |
74 | | - assert custom_lock._owner is None |
75 | | - assert custom_lock._count == 0 |
76 | 68 |
|
77 | | - # Test async acquire/release |
| 69 | + # Verify subclassing and functionality |
78 | 70 | await custom_lock.acquire() |
79 | 71 | assert custom_lock.locked() |
80 | 72 | custom_lock.release() |
|
0 commit comments