From d3bac1b0aefd326efa7a3f85e9a47259e61598a8 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 10 Sep 2019 07:47:32 -0400 Subject: [PATCH] Properly deal with configurable HTML output dirs --- tests/test_pytest_cov.py | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/test_pytest_cov.py b/tests/test_pytest_cov.py index 3905a9ea..6d0e7e78 100644 --- a/tests/test_pytest_cov.py +++ b/tests/test_pytest_cov.py @@ -248,6 +248,25 @@ def test_annotate_output_dir(testdir): assert result.ret == 0 +def test_html(testdir): + script = testdir.makepyfile(SCRIPT) + + result = testdir.runpytest('-v', + '--cov=%s' % script.dirpath(), + '--cov-report=html', + script) + + result.stdout.fnmatch_lines([ + '*- coverage: platform *, python * -*', + 'Coverage HTML written to dir htmlcov', + '*10 passed*', + ]) + dest_dir = testdir.tmpdir.join('htmlcov') + assert dest_dir.check(dir=True) + assert dest_dir.join("index.html").check() + assert result.ret == 0 + + def test_html_output_dir(testdir): script = testdir.makepyfile(SCRIPT) @@ -288,6 +307,28 @@ def test_term_report_does_not_interact_with_html_output(testdir): assert result.ret == 0 +def test_html_configured_output_dir(testdir): + script = testdir.makepyfile(SCRIPT) + testdir.tmpdir.join('.coveragerc').write(""" +[html] +directory = somewhere +""") + result = testdir.runpytest('-v', + '--cov=%s' % script.dirpath(), + '--cov-report=html', + script) + + result.stdout.fnmatch_lines([ + '*- coverage: platform *, python * -*', + 'Coverage HTML written to dir somewhere', + '*10 passed*', + ]) + dest_dir = testdir.tmpdir.join('somewhere') + assert dest_dir.check(dir=True) + assert dest_dir.join("index.html").check() + assert result.ret == 0 + + def test_xml_output_dir(testdir): script = testdir.makepyfile(SCRIPT)