# ReportPortal integration for pytest framework
Pytest plugin for reporting test results of the Pytest to the ReportPortal.
> **DISCLAIMER**: We use Google Analytics for sending anonymous usage information such as agent's and client's names,
> and their versions after a successful launch start. This information might help us to improve both ReportPortal
> backend and client sides. It is used by the ReportPortal team only and is not supposed for sharing with 3rd parties.
[](https://pypi.python.org/pypi/pytest-reportportal)
[](https://pypi.org/project/pytest-reportportal)
[](https://github.com/reportportal/agent-python-pytest/actions/workflows/tests.yml)
[](https://codecov.io/gh/reportportal/agent-python-pytest)
[](https://slack.epmrpp.reportportal.io/)
[](http://stackoverflow.com/questions/tagged/reportportal)
[](http://reportportal.io?style=flat)
## Installation
To install pytest plugin execute next command in a terminal:
```bash
pip install pytest-reportportal
```
Look through the `CONTRIBUTING.rst` for contribution guidelines.
## Configuration
Prepare the config file `pytest.ini` in root directory of tests or specify any one using pytest command line option:
```bash
py.test -c config.cfg
```
The `pytest.ini` file should have next mandatory fields:
- `rp_api_key` - value could be found in the User Profile section
- `rp_project` - name of project in ReportPortal
- `rp_endpoint` - address of ReportPortal Server
Example of `pytest.ini`:
```text
[pytest]
rp_api_key = fb586627-32be-47dd-93c1-678873458a5f
rp_endpoint = http://192.168.1.10:8080
rp_project = user_personal
rp_launch = AnyLaunchName
rp_launch_attributes = 'PyTest' 'Smoke'
rp_launch_description = 'Smoke test'
rp_ignore_attributes = 'xfail' 'usefixture'
```
- The `rp_api_key` can also be set with the environment variable `RP_API_KEY`. This will override the value set for `rp_api_key` in pytest.ini
There are also optional parameters:
https://reportportal.io/docs/log-data-in-reportportal/test-framework-integration/Python/pytest/
## Examples
For logging of the test item flow to ReportPortal, please, use the python logging handler provided by plugin like
below:
in `conftest.py`:
```python
import logging
import pytest
from reportportal_client import RPLogger
@pytest.fixture(scope="session")
def rp_logger():
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logging.setLoggerClass(RPLogger)
return logger
```
in tests:
```python
# In this case only INFO messages will be sent to the ReportPortal.
def test_one(rp_logger):
rp_logger.info("Case1. Step1")
x = "this"
rp_logger.info("x is: %s", x)
assert 'h' in x
# Message with an attachment.
import subprocess
free_memory = subprocess.check_output("free -h".split())
rp_logger.info(
"Case1. Memory consumption",
attachment={
"name": "free_memory.txt",
"data": free_memory,
"mime": "application/octet-stream",
},
)
# This debug message will not be sent to the ReportPortal.
rp_logger.debug("Case1. Debug message")
```
## Launching
To run test with ReportPortal you must provide `--reportportal` flag:
```bash
py.test ./tests --reportportal
```
Check the documentation to find more detailed information about how to integrate pytest with ReportPortal using the
agent:
https://reportportal.io/docs/log-data-in-reportportal/test-framework-integration/Python/pytest/
## Copyright Notice
Licensed under the [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0) license (see the LICENSE file).
Raw data
{
"_id": null,
"home_page": "https://github.com/reportportal/agent-python-pytest",
"name": "pytest-reportportal",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "testing, reporting, reportportal, pytest, agent",
"author": "Report Portal Team",
"author_email": "support@reportportal.io",
"download_url": "https://files.pythonhosted.org/packages/dd/ee/190b64f3a60ba1e09de00f794bd079de1e7b9f20b1ef81be2528fc631323/pytest_reportportal-5.5.2.tar.gz",
"platform": null,
"description": "# ReportPortal integration for pytest framework\n\nPytest plugin for reporting test results of the Pytest to the ReportPortal.\n\n> **DISCLAIMER**: We use Google Analytics for sending anonymous usage information such as agent's and client's names,\n> and their versions after a successful launch start. This information might help us to improve both ReportPortal\n> backend and client sides. It is used by the ReportPortal team only and is not supposed for sharing with 3rd parties.\n\n[](https://pypi.python.org/pypi/pytest-reportportal)\n[](https://pypi.org/project/pytest-reportportal)\n[](https://github.com/reportportal/agent-python-pytest/actions/workflows/tests.yml)\n[](https://codecov.io/gh/reportportal/agent-python-pytest)\n[](https://slack.epmrpp.reportportal.io/)\n[](http://stackoverflow.com/questions/tagged/reportportal)\n[](http://reportportal.io?style=flat)\n\n## Installation\n\nTo install pytest plugin execute next command in a terminal:\n\n```bash\npip install pytest-reportportal\n```\n\nLook through the `CONTRIBUTING.rst` for contribution guidelines.\n\n## Configuration\n\nPrepare the config file `pytest.ini` in root directory of tests or specify any one using pytest command line option:\n\n```bash\npy.test -c config.cfg\n```\n\nThe `pytest.ini` file should have next mandatory fields:\n\n- `rp_api_key` - value could be found in the User Profile section\n- `rp_project` - name of project in ReportPortal\n- `rp_endpoint` - address of ReportPortal Server\n\nExample of `pytest.ini`:\n\n```text\n[pytest]\nrp_api_key = fb586627-32be-47dd-93c1-678873458a5f\nrp_endpoint = http://192.168.1.10:8080\nrp_project = user_personal\nrp_launch = AnyLaunchName\nrp_launch_attributes = 'PyTest' 'Smoke'\nrp_launch_description = 'Smoke test'\nrp_ignore_attributes = 'xfail' 'usefixture'\n```\n\n- The `rp_api_key` can also be set with the environment variable `RP_API_KEY`. This will override the value set for `rp_api_key` in pytest.ini\n\nThere are also optional parameters:\nhttps://reportportal.io/docs/log-data-in-reportportal/test-framework-integration/Python/pytest/\n\n## Examples\n\nFor logging of the test item flow to ReportPortal, please, use the python logging handler provided by plugin like\nbelow:\n\nin `conftest.py`:\n\n```python\nimport logging\n\nimport pytest\n\nfrom reportportal_client import RPLogger\n\n\n@pytest.fixture(scope=\"session\")\ndef rp_logger():\n logger = logging.getLogger(__name__)\n logger.setLevel(logging.DEBUG)\n logging.setLoggerClass(RPLogger)\n return logger\n```\n\nin tests:\n\n```python\n# In this case only INFO messages will be sent to the ReportPortal.\ndef test_one(rp_logger):\n rp_logger.info(\"Case1. Step1\")\n x = \"this\"\n rp_logger.info(\"x is: %s\", x)\n assert 'h' in x\n\n # Message with an attachment.\n import subprocess\n free_memory = subprocess.check_output(\"free -h\".split())\n rp_logger.info(\n \"Case1. Memory consumption\",\n attachment={\n \"name\": \"free_memory.txt\",\n \"data\": free_memory,\n \"mime\": \"application/octet-stream\",\n },\n )\n\n # This debug message will not be sent to the ReportPortal.\n rp_logger.debug(\"Case1. Debug message\")\n```\n\n## Launching\n\nTo run test with ReportPortal you must provide `--reportportal` flag:\n\n```bash\npy.test ./tests --reportportal\n```\n\nCheck the documentation to find more detailed information about how to integrate pytest with ReportPortal using the\nagent:\nhttps://reportportal.io/docs/log-data-in-reportportal/test-framework-integration/Python/pytest/\n\n## Copyright Notice\n\nLicensed under the [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0) license (see the LICENSE file).\n",
"bugtrack_url": null,
"license": "Apache 2.0",
"summary": "Agent for Reporting results of tests to the Report Portal",
"version": "5.5.2",
"project_urls": {
"Homepage": "https://github.com/reportportal/agent-python-pytest"
},
"split_keywords": [
"testing",
" reporting",
" reportportal",
" pytest",
" agent"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "00c8ff5453628205f3e6c6a51fd57de2b56ea9081cfb871d88c5de9041accd23",
"md5": "82b99553053393a978b59f2c4abbb7c5",
"sha256": "a041f47a5231984cf20bffcadb5c41342e83ae39cdfda0b51ae5716e4cc11cac"
},
"downloads": -1,
"filename": "pytest_reportportal-5.5.2-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "82b99553053393a978b59f2c4abbb7c5",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 31785,
"upload_time": "2025-07-08T10:45:18",
"upload_time_iso_8601": "2025-07-08T10:45:18.663644Z",
"url": "https://files.pythonhosted.org/packages/00/c8/ff5453628205f3e6c6a51fd57de2b56ea9081cfb871d88c5de9041accd23/pytest_reportportal-5.5.2-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "ddee190b64f3a60ba1e09de00f794bd079de1e7b9f20b1ef81be2528fc631323",
"md5": "dae703ce77559054b1e5196380c8bd9f",
"sha256": "a00d939776374ea0499ae3cb3ec7171dabe558ac8a766f27a817324b96267147"
},
"downloads": -1,
"filename": "pytest_reportportal-5.5.2.tar.gz",
"has_sig": false,
"md5_digest": "dae703ce77559054b1e5196380c8bd9f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 32250,
"upload_time": "2025-07-08T10:45:19",
"upload_time_iso_8601": "2025-07-08T10:45:19.980786Z",
"url": "https://files.pythonhosted.org/packages/dd/ee/190b64f3a60ba1e09de00f794bd079de1e7b9f20b1ef81be2528fc631323/pytest_reportportal-5.5.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-08 10:45:19",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "reportportal",
"github_project": "agent-python-pytest",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "dill",
"specs": [
[
">=",
"0.3.6"
]
]
},
{
"name": "pytest",
"specs": [
[
">=",
"4.6.10"
]
]
},
{
"name": "reportportal-client",
"specs": [
[
"~=",
"5.6.4"
]
]
},
{
"name": "aenum",
"specs": [
[
">=",
"3.1.0"
]
]
}
],
"tox": true,
"lcname": "pytest-reportportal"
}