File tree Expand file tree Collapse file tree 3 files changed +21
-17
lines changed Expand file tree Collapse file tree 3 files changed +21
-17
lines changed Original file line number Diff line number Diff line change 18
18
19
19
def test_is_generator ():
20
20
def zap ():
21
- yield
21
+ yield # pragma: no cover
22
22
23
23
def foo ():
24
- pass
24
+ pass # pragma: no cover
25
25
26
26
assert is_generator (zap )
27
27
assert not is_generator (foo )
@@ -37,15 +37,20 @@ def __repr__(self):
37
37
38
38
def __getattr__ (self , attr ):
39
39
if not self .left :
40
- raise RuntimeError ("its over" )
40
+ raise RuntimeError ("it's over" ) # pragma: no cover
41
41
self .left -= 1
42
42
return self
43
43
44
44
evil = Evil ()
45
45
46
- with pytest .raises (ValueError ):
47
- res = get_real_func (evil )
48
- print (res )
46
+ with pytest .raises (
47
+ ValueError ,
48
+ match = (
49
+ "could not find real function of <Evil left=800>\n "
50
+ "stopped at <Evil left=800>"
51
+ ),
52
+ ):
53
+ get_real_func (evil )
49
54
50
55
51
56
def test_get_real_func ():
@@ -54,14 +59,14 @@ def test_get_real_func():
54
59
def decorator (f ):
55
60
@wraps (f )
56
61
def inner ():
57
- pass
62
+ pass # pragma: no cover
58
63
59
64
if six .PY2 :
60
65
inner .__wrapped__ = f
61
66
return inner
62
67
63
68
def func ():
64
- pass
69
+ pass # pragma: no cover
65
70
66
71
wrapped_func = decorator (decorator (func ))
67
72
assert get_real_func (wrapped_func ) is func
Original file line number Diff line number Diff line change @@ -30,8 +30,9 @@ def test_fileimport(modfile):
30
30
stderr = subprocess .PIPE ,
31
31
)
32
32
(out , err ) = p .communicate ()
33
- if p .returncode != 0 :
34
- pytest .fail (
35
- "importing %s failed (exitcode %d): out=%r, err=%r"
36
- % (modfile , p .returncode , out , err )
37
- )
33
+ assert p .returncode == 0 , "importing %s failed (exitcode %d): out=%r, err=%r" % (
34
+ modfile ,
35
+ p .returncode ,
36
+ out ,
37
+ err ,
38
+ )
Original file line number Diff line number Diff line change @@ -68,9 +68,7 @@ def test_raises_doesnt():
68
68
passed , skipped , failed = reprec .listoutcomes ()
69
69
assert len (failed ) == 1
70
70
out = failed [0 ].longrepr .reprcrash .message
71
- if not out .find ("DID NOT RAISE" ) != - 1 :
72
- print (out )
73
- pytest .fail ("incorrect raises() output" )
71
+ assert "DID NOT RAISE" in out
74
72
75
73
def test_syntax_error_module (self , testdir ):
76
74
reprec = testdir .inline_runsource ("this is really not python" )
@@ -148,7 +146,7 @@ def test_one(): pass
148
146
)
149
147
try :
150
148
reprec = testdir .inline_run (testdir .tmpdir )
151
- except pytest .skip .Exception :
149
+ except pytest .skip .Exception : # pragma: no covers
152
150
pytest .fail ("wrong skipped caught" )
153
151
reports = reprec .getreports ("pytest_collectreport" )
154
152
assert len (reports ) == 1
You can’t perform that action at this time.
0 commit comments