pytest-upload-report is a plugin for pytest that upload your test report for test results.
Project description
English | 简体中文
pytest-upload-report is a plugin for pytest that upload your test report for test results.
Features
Upload report for allure-pytest.
Upload report for pytest-html.
Requirements
Python >= 3.7
pytest
requests
allure-pytest, if you use allure report.
pytest-html, if you use html report.
Installation
You can install “pytest-upload-report” via pip from PyPI:
$ pip install pytest-upload-report
Usage
A simple example
Directly upload report files to server by upload_url.
On the command line, add upload_url option when run pytest command:
pytest --alluredir=/tmp/my_allure_results --upload_url=http://127.0.0.1:8000/upload
A complete example
Now let us demonstrate how to use in a vaguely real world scenario.
First, you must have a upload api on server, an example for fastapi:
from fastapi import APIRouter, UploadFile, File, Header router = APIRouter(prefix='/api/script', tags=['script']) @router.post("/reports/upload") async def report_upload_by_api( project_id: int, timestamp: int, username: str, sign: str = Header(...), files: List[UploadFile] = File(...), ): ... return 'ok'
Second, edit your conftest.py file, add pytest_send_upload_request hook:
import pytest @pytest.hookimpl(tryfirst=True) def pytest_send_upload_request(upload_url, files, config): from pytest_upload_report.upload_client import SignUploadClient client = SignUploadClient(upload_url, files) client.send_request(config) return True
The other hooks will be blocked from executing, when then hook return True. If you want to upload multiple places, don’t write any return.
Third, edit pytest.init on you test project root dir:
[pytest] addopts = --alluredir=/tmp/my_allure_results --upload_url=http://127.0.0.1:8000/api/script/reports/upload --upload_project_id=4 --upload_username=admin --upload_secret=8FB6CFB4C8CF11EBB523DCA9048E18C3
Finally, run pytest command on you test project root dir:
$ pytest
Also, you can view source code in the example directory.
How to Customize
If the above does not meet your needs, you can customize request client.
Contributing
Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.
License
Distributed under the terms of the MIT license, “pytest-upload-report” is free and open source software
Issues
If you encounter any problems, please file an issue along with a detailed description.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pytest-upload-report-0.1.0.tar.gz
.
File metadata
- Download URL: pytest-upload-report-0.1.0.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 350b7d375f8715f15c5589a4e4f2c9c034905c47a0c8ac640fb3adf95f0e086d |
|
MD5 | b7ce9bc47b10a2f71617333e656856d0 |
|
BLAKE2b-256 | 6444090eb55a5c54ebf504a372be1bef887e7db799beaba8ee15fe49dff7ad8e |