Skip to main content

Plugin for influxdb and pytest integration.

Project description

Influxdb Pytest Plugin

Pytest plugin designed for reporting test results to the ‘InfluxDB’.

Table of Contents

  • About this documentation

  • Usage

  • Examples

  • Send attachment

About this documentation

Welcome to the Influxdb Pytest Plugin documentation!

This style guide provides set of editorial guidelines for anyone using Influxdb Pytest Plugin.



pip install influxdb-pytest-plugin


To run a test with influxdb-pytest-plugin, the ‘–influxdb-pytest’ flag should be provided.

pytest -sv –influxdb-pytest

Prepare the config file pytest.ini in root directory of tests and/or call next to the run command the mandatory config variables which are mentioned below:

The next mandatory fields should be mentioned in pytest.ini or run through command line without ‘–’ prefix:

  • --db_host - host of the influxdb

  • --db_name - name of influxdb table

And here are the optional fields:

  • --db_port - port of the influxdb

  • --db_user - username of influxdb user

  • --db_password - password of influxdb user

  • --project - project name

  • --version - custom version of project

  • --run_id - run id (Can be passed as CI variable)

Example of pytest.ini:

db_host = <DB_HOST>
db_port = <DB_PORT>
db_name = <DB_NAME>
db_user = <DB_USER>
db_password = <DB_PASSWORD>
project = <PROJECT_NAME>
version = <PROJECT_NAME>
run_id = <RUN_ID>

Add custom fields as an additional data

Add custom fields for test result For adding custom fields as an additional data for test result the code like below should be added in

@pytest.fixture(scope='function', autouse=True)
def test_suite(request):
    from influxdb_pytest_plugin import TestResultDTO
    test_result_dto = TestResultDTO()
    test_name = request.node.nodeid
    TestResultDTO.set_tag_values(test_result_dto, test_name, {'tag1': 'tag_value1', 'tag2': 'tag_value2'})
    TestResultDTO.set_field_values(test_result_dto, test_name, {'field1': 'field_value1', 'field2': 'field_value2'})

Add custom fields for suite result For adding custom fields as an additional data for suite result the pytest_terminal_summary pytest plugin like below in

def pytest_terminal_summary(config, terminalreporter):
    from influxdb_pytest_plugin import SuiteResultDTO
    suite_result_dto = SuiteResultDTO()
    SuiteResultDTO.set_tag_values(suite_result_dto, {'tag1': 'tag_value1'})
    SuiteResultDTO.set_field_values(suite_result_dto, {'field1': 'field_value1'})

Send screenshot as attachment

For sending the screenshot to the influxdb, the screenshot_url fixture should be used in function scope like below:

def chrome_driver_init(request, screenshot_url, pytestconfig):
chrome_driver = webdriver.Chrome()
request.cls.driver = chrome_driver
if request.node.rep_call.failed and pytestconfig.getoption('--influxdb-pytest'):
    screenshot_link = 'URL_EXAMPLE'

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

influxdb_pytest_plugin-0.2.44.tar.gz (8.3 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page