Registry / testing / pytest-pytestrail

pytest-pytestrail

JSON →
library0.10.5pypypiunverified

pytest-pytestrail is a Pytest plugin designed to facilitate interaction with TestRail, a web-based test case management tool. It allows users to automatically update TestRail test results directly from their Pytest runs. The current version is 0.10.5, and it typically sees minor updates for compatibility and feature enhancements.

pip install pytest-pytestrail
INSTALL
IMPORT
SIG · PYTEST-PYTESTRAIL
P
pytest-pytestrail
testingpythonv0.10.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

First, create a `pytest.ini` file in your project root to configure TestRail connection details and enable the plugin. Use environment variables for sensitive data like passwords. Then, mark your Pytest tests with `@pytest.mark.testrail()` providing the corresponding TestRail case IDs. Run pytest from the command line.

# pytest.ini [pytest] addopts = --testrail tr-url = https://your.testrail.net/ tr-email = your_email@example.com tr-password = ${TR_PASSWORD} tr-project-name = My Project tr-testrun-name = Automated Test Run # test_example.py import pytest import os # For quickstart, ensure TR_PASSWORD is set in environment, e.g., via export TR_PASSWORD='...' # Or replace ${TR_PASSWORD} with actual password for local testing only (NOT recommended for production) @pytest.mark.testrail('C1234') def test_feature_a_works(): assert True @pytest.mark.testrail('C5678') def test_feature_b_fails(): assert False # This will be reported as failed in TestRail
Debug
Known issues
gotchaTestRail credentials (URL, email, password) must be correctly configured. Incorrect details will lead to 'Failed to connect' or 'Authorization Required' errors. It is highly recommended to use environment variables for passwords.
fix
Ensure `tr-url`, `tr-email`, and `tr-password` (via environment variable or direct value) are correctly set in `pytest.ini` or via command-line flags. Verify network access to the TestRail instance.
affects: All
gotchaThe plugin will not activate without the `--testrail` command-line option or `addopts = --testrail` in `pytest.ini`. Without it, tests will run but results will not be pushed to TestRail.
fix
Add `addopts = --testrail` under the `[pytest]` section in your `pytest.ini` file, or include `--testrail` when running pytest from the command line.
affects: All
gotchaTestRail case IDs used with `@pytest.mark.testrail()` must be valid strings (e.g., 'C1234') and must exist in your specified TestRail project. Invalid or non-existent IDs will result in errors during reporting.
fix
Double-check the TestRail case IDs in your `@pytest.mark.testrail()` decorators against your TestRail project. Ensure they are enclosed in quotes.
affects: All
Errors
Common errors & fixes
Failed to connect to TestRail (HTTP 401: Authorization Required)
Incorrect TestRail email or password, or an invalid API key for a TestRail instance configured to use API keys instead of passwords.
fix
Verify `tr-email` and `tr-password` (or `tr-api-key`) in `pytest.ini` or command-line arguments. Ensure the user has permissions to access the specified TestRail project.
pytest: error: unrecognized arguments: --testrail
The `pytest-pytestrail` plugin is either not installed, or pytest cannot find it in your environment.
fix
Run `pip install pytest-pytestrail` to ensure the plugin is installed in your active Python environment. If using a virtual environment, ensure it's activated.
pytest.mark.testrail must receive a string or list of strings as arguments for case IDs.
Non-string arguments (e.g., integers, booleans) were passed to the `@pytest.mark.testrail()` decorator.
fix
Ensure all TestRail case IDs passed to the decorator are strings, e.g., `@pytest.mark.testrail('C1234')` or `@pytest.mark.testrail(['C1234', 'C5678'])`.
Upgrade
Version history
0.10.5latest on PyPI · released Aug 27, 2020
Audit
Dependencies
pytestrequiredThis is a pytest plugin and requires pytest to run.
Agent activity
4 hits · last 30 days
node
4
Resources
pytest-pytestrail — pip install pytest-pytestrail · libregistry