如何在不更改 css 的情况下共享 pytest-html 的 html 报告

How to share html report of pytest-html with out changing the css

我正在使用 python 3.6 和 pytest-html 生成 HTML 报告。 一切正常,但当我向我的经理分享我的 html 报告时,整个文档的 css 不合适。有人能告诉我发生这种情况的原因和解决方案吗。

我运行时的报告视图:

我与经理共享文档时的报告视图

您似乎没有将 CSS 等一大堆项目与您提供的 html 文件共享。只需将 CSS 代码放在 HTML 中而不是给出路径,它将解决您的问题。

include --self-contained-html 当你调用你的pytest时...比如 pytest your.pyfilename --html=pathandfilename --self-contained-html.

您的结果文件中有内联 css。

html=report.html --独立-html