-
Notifications
You must be signed in to change notification settings - Fork 951
/
Copy pathtest_not_implemented.py
61 lines (48 loc) · 1.55 KB
/
test_not_implemented.py
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
# Copyright 2019 Ram Rachum and collaborators.
# This program is distributed under the MIT license.
import io
import textwrap
import threading
import collections
import types
import os
import sys
from pysnooper.utils import truncate
import pytest
import pysnooper
from pysnooper.variables import needs_parentheses
from pysnooper import pycompat
from .utils import (assert_output, assert_sample_output, VariableEntry,
CallEntry, LineEntry, ReturnEntry, OpcodeEntry,
ReturnValueEntry, ExceptionEntry, ExceptionValueEntry,
SourcePathEntry, CallEndedByExceptionEntry,
ElapsedTimeEntry)
from . import mini_toolbox
def test_rejecting_coroutine_functions():
if sys.version_info[:2] <= (3, 4):
pytest.skip()
code = textwrap.dedent('''
async def foo(x):
return 'lol'
''')
namespace = {}
exec(code, namespace)
foo = namespace['foo']
assert pycompat.iscoroutinefunction(foo)
assert not pycompat.isasyncgenfunction(foo)
with pytest.raises(NotImplementedError):
pysnooper.snoop(color=False)(foo)
def test_rejecting_async_generator_functions():
if sys.version_info[:2] <= (3, 6):
pytest.skip()
code = textwrap.dedent('''
async def foo(x):
yield 'lol'
''')
namespace = {}
exec(code, namespace)
foo = namespace['foo']
assert not pycompat.iscoroutinefunction(foo)
assert pycompat.isasyncgenfunction(foo)
with pytest.raises(NotImplementedError):
pysnooper.snoop(color=False)(foo)