Skip to content

Commit 0afa8ab

Browse files
committed
add tests from @bukzor
1 parent 2603073 commit 0afa8ab

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

pytest-cov/test_pytest_cov.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ def test_foo():
2525
assert False
2626
'''
2727

28+
COVERAGERC_SOURCE = '''\
29+
[run]
30+
source = .
31+
'''
32+
2833
SCRIPT_CHILD = '''
2934
import sys
3035
@@ -108,6 +113,47 @@ def test_central(testdir):
108113
assert result.ret == 0
109114

110115

116+
def test_central_nonspecific(testdir):
117+
script = testdir.makepyfile(SCRIPT)
118+
119+
result = testdir.runpytest('-v',
120+
'--cov',
121+
'--cov-report=term-missing',
122+
script)
123+
124+
result.stdout.fnmatch_lines([
125+
'*- coverage: platform *, python * -*',
126+
'test_central_nonspecific * %s *' % SCRIPT_RESULT,
127+
'*10 passed*'
128+
])
129+
130+
# multi-module coverage report
131+
assert result.stdout.lines[-3].startswith('TOTAL ')
132+
133+
assert result.ret == 0
134+
135+
136+
def test_central_coveragerc(testdir):
137+
script = testdir.makepyfile(SCRIPT)
138+
testdir.tmpdir.join('.coveragerc').write(COVERAGERC_SOURCE)
139+
140+
result = testdir.runpytest('-v',
141+
'--cov',
142+
'--cov-report=term-missing',
143+
script)
144+
145+
result.stdout.fnmatch_lines([
146+
'*- coverage: platform *, python * -*',
147+
'test_central_coveragerc * %s *' % SCRIPT_RESULT,
148+
'*10 passed*',
149+
])
150+
151+
# single-module coverage report
152+
assert result.stdout.lines[-3].startswith('test_central_coveragerc ')
153+
154+
assert result.ret == 0
155+
156+
111157
def test_no_cov_on_fail(testdir):
112158
script = testdir.makepyfile(SCRIPT_FAIL)
113159

0 commit comments

Comments
 (0)