All Projects → reportportal → agent-python-pytest

reportportal / agent-python-pytest

Licence: Apache-2.0 license
Framework integration with PyTest

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to agent-python-pytest

Automationtest
Pytest测试框架,UI, API, DataBase,部分功能已封装,可根据实际需求修改
Stars: ✭ 159 (+84.88%)
Mutual labels:  pytest
Seleniumbase
A Python framework that inspires developers to become better test automation engineers. 🧠💡
Stars: ✭ 2,520 (+2830.23%)
Mutual labels:  pytest
Pytest Qt
pytest plugin for Qt (PyQt4, PyQt5 and PySide) application testing
Stars: ✭ 210 (+144.19%)
Mutual labels:  pytest
Pytest Tricks
😏 Tips and Tricks for the Python Testing Tool
Stars: ✭ 162 (+88.37%)
Mutual labels:  pytest
Pytest Flask Sqlalchemy
A pytest plugin for preserving test isolation in Flask-SQLAlchemy using database transactions.
Stars: ✭ 168 (+95.35%)
Mutual labels:  pytest
Django Test Migrations
Test django schema and data migrations, including migrations' order and best practices.
Stars: ✭ 188 (+118.6%)
Mutual labels:  pytest
Pytest Parallel
A pytest plugin for parallel and concurrent testing
Stars: ✭ 146 (+69.77%)
Mutual labels:  pytest
Best Of Python Dev
🏆 A ranked list of awesome python developer tools and libraries. Updated weekly.
Stars: ✭ 243 (+182.56%)
Mutual labels:  pytest
Pytest Lazy Fixture
It helps to use fixtures in pytest.mark.parametrize
Stars: ✭ 179 (+108.14%)
Mutual labels:  pytest
Pytest Clarity
A plugin to improve the output of pytest with colourful unified diffs
Stars: ✭ 209 (+143.02%)
Mutual labels:  pytest
Usaspending Api
Server application to serve U.S. federal spending data via a RESTful API
Stars: ✭ 166 (+93.02%)
Mutual labels:  pytest
Awesome Pytest
A curated list of awesome pytest resources
Stars: ✭ 170 (+97.67%)
Mutual labels:  pytest
Pytest Chinese Doc
pytest 官方文档的中文翻译,但不仅仅是单纯的翻译,也包含自己的理解和实践。
Stars: ✭ 192 (+123.26%)
Mutual labels:  pytest
Allure Pytest
Deprecated, please use https://github.com/allure-framework/allure-python instead
Stars: ✭ 159 (+84.88%)
Mutual labels:  pytest
Httprunner
One-stop solution for HTTP(S) testing, written in Python.
Stars: ✭ 2,628 (+2955.81%)
Mutual labels:  pytest
Testbook
🧪 📗 Unit test your Jupyter Notebooks the right way
Stars: ✭ 146 (+69.77%)
Mutual labels:  pytest
Cookiecutter Pytest Plugin
A Cookiecutter template for pytest plugins 💻
Stars: ✭ 181 (+110.47%)
Mutual labels:  pytest
ci-testing-python
Sample Microservice App in Python for Testing using pytest, uber/doubles, tox on CI servers like Jenkins and Travis CI using Docker + Docker-Compose for test environment.
Stars: ✭ 37 (-56.98%)
Mutual labels:  pytest
Pytest Selenium
Plugin for running Selenium with pytest
Stars: ✭ 246 (+186.05%)
Mutual labels:  pytest
Cookiecutter Cms
Python-centric Cookiecutter for Molecular Computational Chemistry Packages
Stars: ✭ 197 (+129.07%)
Mutual labels:  pytest

agent-python-pytest

Latest Version Supported python versions Test status Test coverage Join Slack chat!

Pytest plugin for reporting test results of the Pytest to the Report Portal.

  • Usage
  • Installation
  • Configuration
  • Examples
  • Launching
  • Send attachment (screenshots)
  • Troubleshooting
  • Integration with GA
  • Copyright Notice

Usage

Installation

To install pytest plugin execute next command in a terminal:

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:

py.test -c config.cfg

The pytest.ini file should have next mandatory fields:

  • rp_uuid - value could be found in the User Profile section
  • rp_project - name of project in Report Portal
  • rp_endpoint - address of Report Portal Server

Example of pytest.ini:

[pytest]
rp_uuid = 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_uuid can also be set with the environment variable RP_UUID. This will override the value set for rp_uuid in pytest.ini

The following parameters are optional:

  • rp_launch = AnyLaunchName - launch name (could be overridden by pytest --rp-launch option, default value is 'Pytest Launch')
  • rp_launch_id = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - id of the existing launch (the session will not handle the lifecycle of the given launch)
  • rp_launch_attributes = 'PyTest' 'Smoke' 'Env:Python3' - list of attributes for launch
  • rp_parent_item_id = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - id of the existing test item for session to use as parent item for the tests (the session will not handle the lifecycle of the given test item)
  • rp_tests_attributes = 'PyTest' 'Smoke' - list of attributes that will be added for each item in the launch
  • rp_launch_description = 'Smoke test' - launch description (could be overridden by pytest --rp-launch-description option, default value is '')
  • rp_log_batch_size = 20 - size of batch log request
  • rp_log_batch_payload_size = 65000000 - maximum payload size in bytes of async batch log requests
  • rp_log_level = INFO - The log level that will be reported
  • rp_log_format = [%(levelname)7s] (%(name)s) %(message)s (%(filename)s:%(lineno)s) - Format string to be used for logs sent to the service.
  • rp_ignore_attributes = 'xfail' 'usefixture' - Ignore specified pytest markers
  • rp_is_skipped_an_issue = False - Treat skipped tests as required investigation. Default is True.
  • rp_hierarchy_dirs_level = 0 - Directory starting hierarchy level (from pytest.ini level) (default 0)
  • rp_hierarchy_dirs = True - Enables hierarchy for tests directories, default False. Doesn't support 'xdist' plugin.
  • rp_hierarchy_dir_path_separator - Path separator to display directories in test hierarchy. In case of empty value current system path separator will be used (os.path.sep)
  • rp_hierarchy_code - Enables hierarchy for inner classes and parametrized tests, default False. Doesn't support 'xdist' plugin.
  • rp_issue_system_url = https://bugzilla.some.com/show_bug.cgi?id={issue_id} - issue URL (issue_id will be filled by parameter from pytest mark)
  • rp_issue_id_marks = True - Enables adding marks for issue ids (e.g. "issue:123456")
  • rp_verify_ssl = True - Verify SSL when connecting to the server
  • rp_mode = DEFAULT - DEBUG or DEFAULT launch mode. DEBUG launches are displayed in a separate tab and not visible to anyone except owner
  • rp_thread_logging - EXPERIMENTAL - Enables support for reporting logs from threads by patching the builtin Thread class. Use with caution.
  • rp_launch_timeout = 86400 - Maximum time to wait for child processes finish, default value: 86400 seconds (1 day)

If you like to override the above parameters from command line, or from CI environment based on your build, then pass - -o "rp_launch_attributes=Smoke Tests" during invocation.

Examples

For logging of the test item flow to Report Portal, please, use the python logging handler provided by plugin like bellow: in conftest.py:

import logging
import sys

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:

# In this case only INFO messages will be sent to the Report Portal.
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 Report Portal.
    rp_logger.debug("Case1. Debug message")

Plugin can report doc-strings of tests as descriptions:

def test_one():
    """
    Description of the test case which will be sent to Report Portal
    """
    pass

Pytest markers will be attached as attributes to Report Portal items. In the following example attributes 'linux' and 'win32' will be used:

import pytest

@pytest.mark.win32
@pytest.mark.linux
def test_one():
    pass

If you don't want to attach specific markers, list them in rp_ignore_attributes parameter

Launching

To run test with Report Portal you must provide '--reportportal' flag:

py.test ./tests --reportportal

Test issue info

Some pytest marks could be used to specify information about skipped or failed test result.

The following mark fields are used to get information about test issue:

  • issue_id - issue id (or list) in tracking system. This id will be added as comment to test fail result. If URL is specified in pytest ini file (see rp_issue_system_url), id will added as link to tracking system.
  • reason - some comment that will be added to test fail description.
  • issue_type - short name of RP issue type that should be assigned to failed or skipped test.

Example:

@pytest.mark.issue(issue_id="111111", reason="Some bug", issue_type="PB")
def test():
    assert False

Send attachment (screenshots)

https://github.com/reportportal/client-Python#send-attachment-screenshots

Test internal steps, aka "Nested steps"

To implement Nested steps reporting please follow our guide: https://github.com/reportportal/client-Python/wiki/Nested-steps

Also there are examples of usage:

Troubleshooting

If you would like to temporary disable integrations with Report Portal just deactivate pytest_reportportal plugin with command like:

py.test -p no:pytest_reportportal ./tests

Integration with Google analytics

ReportPortal is now supporting integrations with more than 15 test frameworks simultaneously. In order to define the most popular agents and plan the team workload accordingly, we are using Google analytics.

ReportPortal collects information about agent name and its version only. This information is sent to Google Analytics on the launch start. Please help us to make our work effective. If you still want to switch Off Google analytics, please change env variable the way below.

export AGENT_NO_ANALYTICS=1

Copyright Notice

Licensed under the Apache 2.0 license (see the LICENSE file).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].