1
1
import sys
2
2
3
3
import pytest
4
- from _pytest .compat import is_generator
4
+ from _pytest .compat import is_generator , get_real_func
5
5
6
6
7
7
def test_is_generator ():
@@ -15,7 +15,30 @@ def foo():
15
15
assert not is_generator (foo )
16
16
17
17
18
- @pytest .mark .skipif (sys .version_info < (3 , 4 ), reason = 'asyncio available in Python 3.4+' )
18
+ def test_real_func_loop_limit ():
19
+
20
+ class Evil (object ):
21
+ def __init__ (self ):
22
+ self .left = 1000
23
+
24
+ def __repr__ (self ):
25
+ return "<Evil left={left}>" .format (left = self .left )
26
+
27
+ def __getattr__ (self , attr ):
28
+ if not self .left :
29
+ raise RuntimeError ('its over' )
30
+ self .left -= 1
31
+ return self
32
+
33
+ evil = Evil ()
34
+
35
+ with pytest .raises (ValueError ):
36
+ res = get_real_func (evil )
37
+ print (res )
38
+
39
+
40
+ @pytest .mark .skipif (sys .version_info < (3 , 4 ),
41
+ reason = 'asyncio available in Python 3.4+' )
19
42
def test_is_generator_asyncio (testdir ):
20
43
testdir .makepyfile ("""
21
44
from _pytest.compat import is_generator
@@ -27,12 +50,14 @@ def baz():
27
50
def test_is_generator_asyncio():
28
51
assert not is_generator(baz)
29
52
""" )
30
- # avoid importing asyncio into pytest's own process, which in turn imports logging (#8)
53
+ # avoid importing asyncio into pytest's own process,
54
+ # which in turn imports logging (#8)
31
55
result = testdir .runpytest_subprocess ()
32
56
result .stdout .fnmatch_lines (['*1 passed*' ])
33
57
34
58
35
- @pytest .mark .skipif (sys .version_info < (3 , 5 ), reason = 'async syntax available in Python 3.5+' )
59
+ @pytest .mark .skipif (sys .version_info < (3 , 5 ),
60
+ reason = 'async syntax available in Python 3.5+' )
36
61
def test_is_generator_async_syntax (testdir ):
37
62
testdir .makepyfile ("""
38
63
from _pytest.compat import is_generator
0 commit comments