{"id":8537,"library":"pytest-pytestrail","title":"Pytest TestRail Plugin","description":"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.","status":"active","version":"0.10.5","language":"en","source_language":"en","source_url":"https://github.com/tolstislon/pytest-pytestrail","tags":["pytest","plugin","testrail","testing","automation","reporting"],"install":[{"cmd":"pip install pytest-pytestrail","lang":"bash","label":"Install plugin"}],"dependencies":[{"reason":"This is a pytest plugin and requires pytest to run.","package":"pytest","optional":false}],"imports":[],"quickstart":{"code":"# pytest.ini\n[pytest]\naddopts = --testrail\ntr-url = https://your.testrail.net/\ntr-email = your_email@example.com\ntr-password = ${TR_PASSWORD}\ntr-project-name = My Project\ntr-testrun-name = Automated Test Run\n\n# test_example.py\nimport pytest\nimport os\n\n# For quickstart, ensure TR_PASSWORD is set in environment, e.g., via export TR_PASSWORD='...' \n# Or replace ${TR_PASSWORD} with actual password for local testing only (NOT recommended for production)\n\n@pytest.mark.testrail('C1234')\ndef test_feature_a_works():\n    assert True\n\n@pytest.mark.testrail('C5678')\ndef test_feature_b_fails():\n    assert False # This will be reported as failed in TestRail\n","lang":"python","description":"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."},"warnings":[{"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.","message":"TestRail 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.","severity":"gotcha","affected_versions":"All"},{"fix":"Add `addopts = --testrail` under the `[pytest]` section in your `pytest.ini` file, or include `--testrail` when running pytest from the command line.","message":"The 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.","severity":"gotcha","affected_versions":"All"},{"fix":"Double-check the TestRail case IDs in your `@pytest.mark.testrail()` decorators against your TestRail project. Ensure they are enclosed in quotes.","message":"TestRail 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.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"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.","cause":"Incorrect TestRail email or password, or an invalid API key for a TestRail instance configured to use API keys instead of passwords.","error":"Failed to connect to TestRail (HTTP 401: Authorization Required)"},{"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.","cause":"The `pytest-pytestrail` plugin is either not installed, or pytest cannot find it in your environment.","error":"pytest: error: unrecognized arguments: --testrail"},{"fix":"Ensure all TestRail case IDs passed to the decorator are strings, e.g., `@pytest.mark.testrail('C1234')` or `@pytest.mark.testrail(['C1234', 'C5678'])`.","cause":"Non-string arguments (e.g., integers, booleans) were passed to the `@pytest.mark.testrail()` decorator.","error":"pytest.mark.testrail must receive a string or list of strings as arguments for case IDs."}]}