pytest plugin for generating HTML reports
Project description
pytest-xhtml
pytest-xhtml is a plugin for pytest that generates a HTML report for test results.
⚠️
pytest-xhtmlis the alternative library forpytest-html. If you have installedpytest-html, please uninstall it first.
install
# pip install
pip install pytest-xhtml
usage
- unit test
cd testing_unit
pytest test_sample.py --html=report.html
- e2e test
# install playwright library
pip install pytest-playwright
playwright install chromium
cd testing_e2e
pytest test_playwright.py --html=report.html
- http test
# install pytest-req library
pip install pytest-req
cd testing_req
pytest test_req.py --html=report.html
VS pytest-html
pytest-xhtml is fully compatible with pytest-html. The only difference is a more beautiful UI style.
| Feature | pytest-html | pytest-xhtml |
|---|---|---|
| UI Style | Traditional table layout | ✨ Modern card-based dashboard (More beautiful!) |
| Generate HTML Report | pytest --html=report.html |
🟰 |
| Self-contained Report | pytest --html=report.html --self-contained-html |
🟰 |
| Custom CSS | pytest --html=report.html --css=style.css |
🟰 |
| Report Streaming | generate_report_on_test = true (pytest.ini) |
🟰 |
| Environment Redaction | environment_table_redact_list (regex) |
🟰 |
| Collapsed Rows | render_collapsed = passed,failed (pytest.ini) |
🟰 |
| Initial Sort | initial_sort = result (pytest.ini) |
🟰 |
| Hook: Report Title | pytest_html_report_title(report) |
🟰 (rename to pytest_xhtml_*) |
| Hook: Results Summary | pytest_html_results_summary(prefix, summary, postfix) |
🟰 (rename to pytest_xhtml_*) |
| Hook: Table Header | pytest_html_results_table_header(cells) |
🟰 (rename to pytest_xhtml_*) |
| Hook: Table Row | pytest_html_results_table_row(report, cells) |
🟰 (rename to pytest_xhtml_*) |
| Hook: Table HTML | pytest_html_results_table_html(report, data) |
🟰 (rename to pytest_xhtml_*) |
| Hook: Duration Format | pytest_html_duration_format(duration) |
🟰 (rename to pytest_xhtml_*) |
| Extras: HTML | extras.html('<div>...</div>') |
🟰 |
| Extras: JSON | extras.json({'name': 'pytest'}) |
🟰 |
| Extras: Text | extras.text('some text') |
🟰 |
| Extras: URL | extras.url('http://example.com/') |
🟰 |
| Extras: Image | extras.image(path_or_data, mime_type, ext) |
🟰 |
| Extras: PNG/JPG/SVG | extras.png() / extras.jpg() / extras.svg() |
🟰 |
| Extras Fixture | def test_x(extras): |
🟰 |
| ANSI Code Support | Via ansi2html (optional) |
🟰 |
Develop
# develop
git clone https://github.com/seldomQA/pytest-xhtml.git
cd pytest-xhtml
pip install .
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_xhtml-0.5.0.tar.gz.
File metadata
- Download URL: pytest_xhtml-0.5.0.tar.gz
- Upload date:
- Size: 4.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
041f01fe5dc854321e98b59b358774d685ef3da6d522218af90b29a0a097df65
|
|
| MD5 |
a06813651ddd25c3e85020cdc8be149a
|
|
| BLAKE2b-256 |
4d3f09ebd29e89dfe06e74aaaefbd0ee955d04b0b1dadc9ae7ffcb00a6e5ffa2
|
File details
Details for the file pytest_xhtml-0.5.0-py3-none-any.whl.
File metadata
- Download URL: pytest_xhtml-0.5.0-py3-none-any.whl
- Upload date:
- Size: 33.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d66be253a44c72621e55f98b25291c2147be2b06aee17fde05a3edca2c1f49a4
|
|
| MD5 |
9f92093089fb54796c94c24279ac5345
|
|
| BLAKE2b-256 |
20bb5b9e7c7db42995baf91f74efee8c0b1a9635e9c489bf7e2ebad934dfd2c1
|