in pytest_azurepipelines.py [0:0]
def inline_css_into_each_html_report_file(reportdir):
"""
Since <link> does not work inside the iframe used by Azure DevOps,
inline the CSS styles into each HTML file generated by pytest report.
This enables a good UX when reading reports in the portal.
"""
style_fragment = "\n<style>\n" + get_resource_file_content("style.css") + "\n</style>\n"
# since pytest-cov generates a flat folder, we don't need recursion here
for file in os.listdir(reportdir):
if file.endswith(".html"):
full_path = os.path.join(reportdir, file)
with open(full_path, mode="rt", encoding="utf8") as f:
new_text = f.read().replace("</head>", style_fragment + "</head>")
with open(full_path, mode="wt", encoding="utf8") as f:
f.write(new_text)