blob: 5fb6d6a0d52fc23bd49b5b974537a8a589a2a9fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
"""Test that an async context manager receives a proper object."""
# pylint: disable=missing-docstring, import-error, too-few-public-methods
import contextlib
from ala import Portocala
@contextlib.contextmanager
def ctx_manager():
yield
class ContextManager:
def __enter__(self):
pass
def __exit__(self, *args):
pass
class PartialAsyncContextManager:
def __aenter__(self):
pass
class SecondPartialAsyncContextManager:
def __aexit__(self, *args):
pass
class UnknownBases(Portocala):
def __aenter__(self):
pass
class AsyncManagerMixin:
pass
class GoodAsyncManager:
def __aenter__(self):
pass
def __aexit__(self, *args):
pass
class InheritExit:
def __aexit__(self, *args):
pass
class SecondGoodAsyncManager(InheritExit):
def __aenter__(self):
pass
async def bad_coro():
async with 42: # [not-async-context-manager]
pass
async with ctx_manager(): # [not-async-context-manager]
pass
async with ContextManager(): # [not-async-context-manager]
pass
async with PartialAsyncContextManager(): # [not-async-context-manager]
pass
async with SecondPartialAsyncContextManager(): # [not-async-context-manager]
pass
async def good_coro():
async with UnknownBases():
pass
async with AsyncManagerMixin():
pass
async with GoodAsyncManager():
pass
async with SecondGoodAsyncManager():
pass
|