The Azure DevOps uses an <iframe> tag to sandbox the automatically-generated HTML coverage report. This results in bad formatting because in the <iframe>:
no external CSS are allowed (this is already addressed by CSS inlining)
no external JS is allowed (not addressed here)
some HTML elements are deleted/not shown correctly, such as the <main> tag.
See for example #36.
This PR addresses the last point, by replacing the main tag in the HTML coverage report with an innocuous div tag. The static CSS stylesheet is updated accordingly.
My test strategy has been the following:
git checkout master
./run.sh # Afterwards, open wrapper.html with a browser to see the outcome BEFORE
git checkout fzardi/fix-main-tag
./run.sh # Afterwards, open wrapper.html with a browser to see the outcome AFTER
where "run.sh" is the following bash script (NOTE: you might need to fix the path to the second file embedded by the ifram):
#!/usr/bin/env bash
set -uexo pipefail
rm -f wrapper.html
rm -rf .venv
rm -rf htmlcov
python -m venv .venv
source .venv/bin/activate
pip install .
pip install pytest-cov
pytest tests -v -m "not testfail" --cov --cov-report=html
cat <<EOF > wrapper.html
<!DOCTYPE html>
<head>
<style>
iframe {
height: 400px;
width: 800px;
background: #f8f8f8;
}
</style>
</head>
<body>
<iframe sandbox="" src="./htmlcov/index.html"></iframe>
<iframe sandbox="" src="./htmlcov/d_a44f0ac069e85531_test_azurepipelines_py.html"></iframe>
</body>
</html>
EOF
deactivate
rm -rf .venv
# Now open the "wrapper.html" file with a browser for a preview
The Azure DevOps uses an
<iframe>
tag to sandbox the automatically-generated HTML coverage report. This results in bad formatting because in the<iframe>
:<main>
tag.See for example #36.
This PR addresses the last point, by replacing the
main
tag in the HTML coverage report with an innocuousdiv
tag. The static CSS stylesheet is updated accordingly.My test strategy has been the following:
where "run.sh" is the following bash script (NOTE: you might need to fix the path to the second file embedded by the ifram):
Closes #36.