Skip to content

Commit d3bac1b

Browse files
nedbationelmc
authored andcommitted
Properly deal with configurable HTML output dirs
1 parent abac74e commit d3bac1b

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/test_pytest_cov.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,25 @@ def test_annotate_output_dir(testdir):
248248
assert result.ret == 0
249249

250250

251+
def test_html(testdir):
252+
script = testdir.makepyfile(SCRIPT)
253+
254+
result = testdir.runpytest('-v',
255+
'--cov=%s' % script.dirpath(),
256+
'--cov-report=html',
257+
script)
258+
259+
result.stdout.fnmatch_lines([
260+
'*- coverage: platform *, python * -*',
261+
'Coverage HTML written to dir htmlcov',
262+
'*10 passed*',
263+
])
264+
dest_dir = testdir.tmpdir.join('htmlcov')
265+
assert dest_dir.check(dir=True)
266+
assert dest_dir.join("index.html").check()
267+
assert result.ret == 0
268+
269+
251270
def test_html_output_dir(testdir):
252271
script = testdir.makepyfile(SCRIPT)
253272

@@ -288,6 +307,28 @@ def test_term_report_does_not_interact_with_html_output(testdir):
288307
assert result.ret == 0
289308

290309

310+
def test_html_configured_output_dir(testdir):
311+
script = testdir.makepyfile(SCRIPT)
312+
testdir.tmpdir.join('.coveragerc').write("""
313+
[html]
314+
directory = somewhere
315+
""")
316+
result = testdir.runpytest('-v',
317+
'--cov=%s' % script.dirpath(),
318+
'--cov-report=html',
319+
script)
320+
321+
result.stdout.fnmatch_lines([
322+
'*- coverage: platform *, python * -*',
323+
'Coverage HTML written to dir somewhere',
324+
'*10 passed*',
325+
])
326+
dest_dir = testdir.tmpdir.join('somewhere')
327+
assert dest_dir.check(dir=True)
328+
assert dest_dir.join("index.html").check()
329+
assert result.ret == 0
330+
331+
291332
def test_xml_output_dir(testdir):
292333
script = testdir.makepyfile(SCRIPT)
293334

0 commit comments

Comments
 (0)