Skip to main content

pytest-tytest

PyPI version Python versions See Build Status on Travis CI

Typhoon HIL plugin for pytest

Features

  • specify test parameters in a python module

  • reference them in pytest.mark.parametrize decorators

  • mark tests as Jira+Xray issues

  • send test reports directly to Xray using Xray’s REST API

Requirements

  • pytest 5+

  • pytz, tzlocal

  • requests 2.23+

Installation

You can install “pytest-tytest” via pip from PyPI:

$ pip install pytest-tytest

Usage

Credentials for Jira and Xray

Put credentials needed to access Jira and Xray in environment variables or a file.

  • XRAY_HOST: Xray URL, defaults to https://xray.cloud.xpand-it.com

  • XRAY_CLIENT_ID: Client ID of your Xray API key

  • XRAY_CLIENT_SECRET: Client secret of your Xray API key

  • JIRA_HOST: Your Jira host, probably https://mycompany.atlassian.net

  • JIRA_USER: Your Jira account username, probably your email address

  • JIRA_PASSWORD: Your Jira account password

You can define credentials as environment variables:

export XRAY_CLIENT_ID=...
export XRAY_CLIENT_SECRET=...

Or you can store credentials in a file, for example, /private/secrets:

XRAY_CLIENT_ID=...
XRAY_CLIENT_SECRET=...
...

Don’t put the variable values in quotes.

If you use a file to store credentials, you should use the secrets command line parameter:

pytest –secrets=/private/secrets

Test parameters defined in Python modules

Create a test parameter definition file as a Python module, such as this:

# myparams.py
import numpy as np

v_range = [277.0, 278.0]
f_range = np.arange(58, 63, 0.2)
vdc_range = [820.0]

class StayConnected:
    voltage_dip_perc = [22, 45, 85, 95]
    dip_total_time_pu = 0.95

All module attributes will be available at runtime as tytest.runtime_settings.Config.attr_name, for example:

from tytest.runtime_settings import Config as C

@python.mark.parametrize('v_range', C.v_range)
def test_something(v_range):
    pass

Specify which parameter definition file you are using in command line:

pytest --runconfig=myparams.py

Marking tests for Xray reporting

Mark your tests with Jira issue keys, such as this:

@pytest.mark.xray(test_key='PRJ-123')
def test_something():
    pass

Associate your test run with a test plan in Xray using the test plan key:

pytest --xray-plan-key=DEMO-1234

If you want to ignore potential networking errors while submitting test reports to Xray, turn this flag on:

pytest --xray-plan-key=DEMO-1234 --xray-fail-silently=True

Command-line parameter summary

pytest invocation now has some additional command line parameters:

--runconfig=RUNCONFIG
                      Specify test config script
--secrets=SECRETS     Full path to secrets file
--xray-plan-key=XRAY_PLAN_KEY
                      Key of the Xray issue that represents the test plan that is being run
--xray-fail-silently=XRAY_FAIL_SILENTLY
                      Ignore Xray communication errors
--allure-url=ALLURE_URL
                      URL pointing to the Allure report

An example of invoking pytest:

pytest --runconfig=myparams.py --secrets=/private/secrets --xray-plan-key=PRJ-321 --xray-fail-silently=True --allure-url=https://jenkins.mycompany.com/jobs/my_job/123/allure

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-tytest” is free and open source software

Issues

If you encounter any problems, please file an issue along with a detailed description.

Metadata

Release files for pytest-tytest 0.1.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-tytest 0.1.11
File Size Uploaded
pytest-tytest-0.1.11.tar.gz 7.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-tytest 0.1.11
File Interpreter ABI Platform
pytest_tytest-0.1.11-py3-none-any.whl Python 3 none any Details

Total release size: 18.2 kB

Release files / pytest-tytest-0.1.11.tar.gz

Download URL pytest-tytest-0.1.11.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8dde863cd96ab67a6e51293001f6472f55a0a0d27b7b21de389591856437d61c
BLAKE2b-256 checksum
How to use checksums
bee1e16ce2f0db78bd1c3cb7c07de6c3ff9e3a507df153b2fd2f6cffa576e269
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

Release files / pytest_tytest-0.1.11-py3-none-any.whl

Download URL pytest_tytest-0.1.11-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5235ad30dcf1033006cbff57236a1571b533284ef4f72dfe736726a2d46cc0e6
BLAKE2b-256 checksum
How to use checksums
ec5fba97998984b89f20d6e4a16d9b1149512ecf707325b244a7f9fd3f80739c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

Release history Release notifications | RSS feed

0.1.13

2 release files

0.1.12

2 release files

This release

0.1.11 This release

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page