reportportal-client


Namereportportal-client JSON
Version 5.5.6 PyPI version JSON
download
home_pagehttps://github.com/reportportal/client-Python
SummaryPython client for ReportPortal v5.
upload_time2024-03-20 13:27:25
maintainerNone
docs_urlNone
authorReportPortal Team
requires_pythonNone
licenseApache 2.0.
keywords testing reporting reportportal client
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ReportPortal python client

[![PyPI](https://img.shields.io/pypi/v/reportportal-client.svg?maxAge=259200)](https://pypi.python.org/pypi/reportportal-client)
[![Python versions](https://img.shields.io/pypi/pyversions/reportportal-client.svg)](https://pypi.org/project/reportportal-client)
[![Build Status](https://github.com/reportportal/client-Python/actions/workflows/tests.yml/badge.svg)](https://github.com/reportportal/client-Python/actions/workflows/tests.yml)
[![codecov.io](https://codecov.io/gh/reportportal/client-Python/branch/develop/graph/badge.svg)](https://codecov.io/gh/reportportal/client-Python)
[![Join Slack chat!](https://img.shields.io/badge/slack-join-brightgreen.svg)](https://slack.epmrpp.reportportal.io/)
[![stackoverflow](https://img.shields.io/badge/reportportal-stackoverflow-orange.svg?style=flat)](http://stackoverflow.com/questions/tagged/reportportal)
[![Build with Love](https://img.shields.io/badge/build%20with-❤%EF%B8%8F%E2%80%8D-lightgrey.svg)](http://reportportal.io?style=flat)

Library used only for implementors of custom listeners for ReportPortal

## Already implemented listeners:

- [PyTest Framework](https://github.com/reportportal/agent-python-pytest)
- [Robot Framework](https://github.com/reportportal/agent-Python-RobotFramework)
- [Behave Framework](https://github.com/reportportal/agent-python-behave)
- [Nose Framework (archived)](https://github.com/reportportal/agent-python-nosetests)

## Installation

The latest stable version is available on PyPI:

```
pip install reportportal-client
```

## Usage

Basic usage example:

```python
import os
import subprocess
from mimetypes import guess_type

from reportportal_client import RPClient
from reportportal_client.helpers import timestamp

endpoint = "http://docker.local:8080"
project = "default"
# You can get UUID from user profile page in the ReportPortal.
api_key = "1adf271d-505f-44a8-ad71-0afbdf8c83bd"
launch_name = "Test launch"
launch_doc = "Testing logging with attachment."


client = RPClient(endpoint=endpoint, project=project,
                  api_key=api_key)

# Start log upload thread
client.start()

# Start launch.
launch = client.start_launch(name=launch_name,
                             start_time=timestamp(),
                             description=launch_doc)

item_id = client.start_test_item(name="Test Case",
                                 description="First Test Case",
                                 start_time=timestamp(),
                                 attributes=[{"key": "key", "value": "value"},
                                             {"value", "tag"}],
                                 item_type="STEP",
                                 parameters={"key1": "val1",
                                             "key2": "val2"})

# Create text log message with INFO level.
client.log(time=timestamp(),
           message="Hello World!",
           level="INFO")

# Create log message with attached text output and WARN level.
client.log(time=timestamp(),
           message="Too high memory usage!",
           level="WARN",
           attachment={
               "name": "free_memory.txt",
               "data": subprocess.check_output("free -h".split()),
               "mime": "text/plain"
           })

# Create log message with binary file, INFO level and custom mimetype.
image = "/tmp/image.png"
with open(image, "rb") as fh:
    attachment = {
        "name": os.path.basename(image),
        "data": fh.read(),
        "mime": guess_type(image)[0] or "application/octet-stream"
    }
    client.log(timestamp(), "Screen shot of issue.", "INFO", attachment)

client.finish_test_item(item_id=item_id, end_time=timestamp(), status="PASSED")

# Finish launch.
client.finish_launch(end_time=timestamp())

# Due to async nature of the service we need to call terminate() method which
# ensures all pending requests to server are processed.
# Failure to call terminate() may result in lost data.
client.terminate()
```

# Send attachment (screenshots)

The client uses `requests` library for working with RP and the same semantics
to work with attachments (data).

To log an attachment you need to pass file content and metadata to ``

```python
import logging

from reportportal_client import RPLogger, RPLogHandler

logging.setLoggerClass(RPLogger)
rp_logger = logging.getLogger(__name__)
rp_logger.setLevel(logging.DEBUG)
rp_logger.addHandler(RPLogHandler())

screenshot_file_path = 'path/to/file.png'

with open(screenshot_file_path, "rb") as image_file:
    file_data = image_file.read()

    # noinspection PyArgumentList
    rp_logger.info(
        "Some Text Here",
        attachment={"name": "test_name_screenshot.png",
                    "data": file_data,
                    "mime": "image/png"}
    )
```

# Copyright Notice

Licensed under the [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)
license (see the LICENSE.txt file).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/reportportal/client-Python",
    "name": "reportportal-client",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "testing, reporting, reportportal, client",
    "author": "ReportPortal Team",
    "author_email": "support@reportportal.io",
    "download_url": "https://files.pythonhosted.org/packages/d7/ba/0779832c857435ae36433044fdf182f6c7b41c2e8eaf31321caa944bfdc7/reportportal-client-5.5.6.tar.gz",
    "platform": null,
    "description": "# ReportPortal python client\n\n[![PyPI](https://img.shields.io/pypi/v/reportportal-client.svg?maxAge=259200)](https://pypi.python.org/pypi/reportportal-client)\n[![Python versions](https://img.shields.io/pypi/pyversions/reportportal-client.svg)](https://pypi.org/project/reportportal-client)\n[![Build Status](https://github.com/reportportal/client-Python/actions/workflows/tests.yml/badge.svg)](https://github.com/reportportal/client-Python/actions/workflows/tests.yml)\n[![codecov.io](https://codecov.io/gh/reportportal/client-Python/branch/develop/graph/badge.svg)](https://codecov.io/gh/reportportal/client-Python)\n[![Join Slack chat!](https://img.shields.io/badge/slack-join-brightgreen.svg)](https://slack.epmrpp.reportportal.io/)\n[![stackoverflow](https://img.shields.io/badge/reportportal-stackoverflow-orange.svg?style=flat)](http://stackoverflow.com/questions/tagged/reportportal)\n[![Build with Love](https://img.shields.io/badge/build%20with-\u2764%EF%B8%8F%E2%80%8D-lightgrey.svg)](http://reportportal.io?style=flat)\n\nLibrary used only for implementors of custom listeners for ReportPortal\n\n## Already implemented listeners:\n\n- [PyTest Framework](https://github.com/reportportal/agent-python-pytest)\n- [Robot Framework](https://github.com/reportportal/agent-Python-RobotFramework)\n- [Behave Framework](https://github.com/reportportal/agent-python-behave)\n- [Nose Framework (archived)](https://github.com/reportportal/agent-python-nosetests)\n\n## Installation\n\nThe latest stable version is available on PyPI:\n\n```\npip install reportportal-client\n```\n\n## Usage\n\nBasic usage example:\n\n```python\nimport os\nimport subprocess\nfrom mimetypes import guess_type\n\nfrom reportportal_client import RPClient\nfrom reportportal_client.helpers import timestamp\n\nendpoint = \"http://docker.local:8080\"\nproject = \"default\"\n# You can get UUID from user profile page in the ReportPortal.\napi_key = \"1adf271d-505f-44a8-ad71-0afbdf8c83bd\"\nlaunch_name = \"Test launch\"\nlaunch_doc = \"Testing logging with attachment.\"\n\n\nclient = RPClient(endpoint=endpoint, project=project,\n                  api_key=api_key)\n\n# Start log upload thread\nclient.start()\n\n# Start launch.\nlaunch = client.start_launch(name=launch_name,\n                             start_time=timestamp(),\n                             description=launch_doc)\n\nitem_id = client.start_test_item(name=\"Test Case\",\n                                 description=\"First Test Case\",\n                                 start_time=timestamp(),\n                                 attributes=[{\"key\": \"key\", \"value\": \"value\"},\n                                             {\"value\", \"tag\"}],\n                                 item_type=\"STEP\",\n                                 parameters={\"key1\": \"val1\",\n                                             \"key2\": \"val2\"})\n\n# Create text log message with INFO level.\nclient.log(time=timestamp(),\n           message=\"Hello World!\",\n           level=\"INFO\")\n\n# Create log message with attached text output and WARN level.\nclient.log(time=timestamp(),\n           message=\"Too high memory usage!\",\n           level=\"WARN\",\n           attachment={\n               \"name\": \"free_memory.txt\",\n               \"data\": subprocess.check_output(\"free -h\".split()),\n               \"mime\": \"text/plain\"\n           })\n\n# Create log message with binary file, INFO level and custom mimetype.\nimage = \"/tmp/image.png\"\nwith open(image, \"rb\") as fh:\n    attachment = {\n        \"name\": os.path.basename(image),\n        \"data\": fh.read(),\n        \"mime\": guess_type(image)[0] or \"application/octet-stream\"\n    }\n    client.log(timestamp(), \"Screen shot of issue.\", \"INFO\", attachment)\n\nclient.finish_test_item(item_id=item_id, end_time=timestamp(), status=\"PASSED\")\n\n# Finish launch.\nclient.finish_launch(end_time=timestamp())\n\n# Due to async nature of the service we need to call terminate() method which\n# ensures all pending requests to server are processed.\n# Failure to call terminate() may result in lost data.\nclient.terminate()\n```\n\n# Send attachment (screenshots)\n\nThe client uses `requests` library for working with RP and the same semantics\nto work with attachments (data).\n\nTo log an attachment you need to pass file content and metadata to ``\n\n```python\nimport logging\n\nfrom reportportal_client import RPLogger, RPLogHandler\n\nlogging.setLoggerClass(RPLogger)\nrp_logger = logging.getLogger(__name__)\nrp_logger.setLevel(logging.DEBUG)\nrp_logger.addHandler(RPLogHandler())\n\nscreenshot_file_path = 'path/to/file.png'\n\nwith open(screenshot_file_path, \"rb\") as image_file:\n    file_data = image_file.read()\n\n    # noinspection PyArgumentList\n    rp_logger.info(\n        \"Some Text Here\",\n        attachment={\"name\": \"test_name_screenshot.png\",\n                    \"data\": file_data,\n                    \"mime\": \"image/png\"}\n    )\n```\n\n# Copyright Notice\n\nLicensed under the [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)\nlicense (see the LICENSE.txt file).\n",
    "bugtrack_url": null,
    "license": "Apache 2.0.",
    "summary": "Python client for ReportPortal v5.",
    "version": "5.5.6",
    "project_urls": {
        "Download": "https://github.com/reportportal/client-Python/tarball/5.5.6",
        "Homepage": "https://github.com/reportportal/client-Python"
    },
    "split_keywords": [
        "testing",
        " reporting",
        " reportportal",
        " client"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1413a651b482156109c296a8b651cae16fa266f3f401f192578dcc41ecf21ec1",
                "md5": "610082b3a12cbe47f4293a8f5bb41cc4",
                "sha256": "dabde0857a8ea2b1ebfbe655caaaec6d2bda17b3b457a90171bc1252780f1a08"
            },
            "downloads": -1,
            "filename": "reportportal_client-5.5.6-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "610082b3a12cbe47f4293a8f5bb41cc4",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 77571,
            "upload_time": "2024-03-20T13:27:23",
            "upload_time_iso_8601": "2024-03-20T13:27:23.494934Z",
            "url": "https://files.pythonhosted.org/packages/14/13/a651b482156109c296a8b651cae16fa266f3f401f192578dcc41ecf21ec1/reportportal_client-5.5.6-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d7ba0779832c857435ae36433044fdf182f6c7b41c2e8eaf31321caa944bfdc7",
                "md5": "2fd9d115b0b18f2172447b58d119e805",
                "sha256": "10a5099a84b9f1acb768393110f6466aade8c738ac66dd5ed22c921b37745152"
            },
            "downloads": -1,
            "filename": "reportportal-client-5.5.6.tar.gz",
            "has_sig": false,
            "md5_digest": "2fd9d115b0b18f2172447b58d119e805",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 60484,
            "upload_time": "2024-03-20T13:27:25",
            "upload_time_iso_8601": "2024-03-20T13:27:25.564323Z",
            "url": "https://files.pythonhosted.org/packages/d7/ba/0779832c857435ae36433044fdf182f6c7b41c2e8eaf31321caa944bfdc7/reportportal-client-5.5.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-20 13:27:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "reportportal",
    "github_project": "client-Python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "reportportal-client"
}
        
Elapsed time: 0.22496s