blob: 138d76dfa4ec88a2ab389f3a25e80e86c66ae726 (
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, useless-object-inheritance
import contextlib
from ala import Portocala
@contextlib.contextmanager
def ctx_manager():
yield
class ContextManager(object):
def __enter__(self):
pass
def __exit__(self, *args):
pass
class PartialAsyncContextManager(object):
def __aenter__(self):
pass
class SecondPartialAsyncContextManager(object):
def __aexit__(self, *args):
pass
class UnknownBases(Portocala):
def __aenter__(self):
pass
class AsyncManagerMixin(object):
pass
class GoodAsyncManager(object):
def __aenter__(self):
pass
def __aexit__(self, *args):
pass
class InheritExit(object):
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
|