https://github.com/tolstislon/testrail-api
Python wrapper of the TestRail API
https://github.com/tolstislon/testrail-api
python python-wrapper testrail testrail-api
Last synced: 2 months ago
JSON representation
Python wrapper of the TestRail API
- Host: GitHub
- URL: https://github.com/tolstislon/testrail-api
- Owner: tolstislon
- License: mit
- Created: 2018-11-25T15:15:43.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-12-30T09:13:15.000Z (3 months ago)
- Last Synced: 2026-01-02T18:48:34.504Z (3 months ago)
- Topics: python, python-wrapper, testrail, testrail-api
- Language: Python
- Homepage:
- Size: 267 KB
- Stars: 35
- Watchers: 2
- Forks: 20
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Testrail Api
[](https://pypi.org/project/testrail-api/)
[](https://pepy.tech/project/testrail-api)
[](https://pypi.org/project/testrail-api/)
[](https://pypi.org/project/testrail-api/)
[](https://github.com/tolstislon/testrail-api)
This is a Python wrapper of the TestRail API according
to [the official documentation](https://www.gurock.com/testrail/docs/api)
Install
----
Install using pip with
```bash
pip install testrail-api
```
##### Support environment variables
```dotenv
TESTRAIL_URL=https://example.testrail.com/
TESTRAIL_EMAIL=example@mail.com
TESTRAIL_PASSWORD=password
```
Example
----
```python
from datetime import datetime
from testrail_api import TestRailAPI
api = TestRailAPI("https://example.testrail.com/", "example@mail.com", "password")
# if use environment variables
# api = TestRailAPI()
new_milestone = api.milestones.add_milestone(
project_id=1,
name="New milestone",
start_on=datetime.now()
)
my_test_run = api.runs.add_run(
project_id=1,
suite_id=2,
name="My test run",
include_all=True,
milestone_id=new_milestone["id"]
)
result = api.results.add_result_for_case(
run_id=my_test_run["id"],
case_id=5,
status_id=1,
comment="Pass",
version="1"
)
attach = "screenshots/attach.jpg"
api.attachments.add_attachment_to_result(result["id"], attach)
api.runs.close_run(my_test_run["id"])
api.milestones.update_milestone(new_milestone["id"], is_completed=True)
```
#### Custom response handler
```python
from datetime import datetime
import simplejson
from testrail_api import TestRailAPI
def my_handler(response):
if response.ok:
return simplejson.loads(response.text)
return 'Error'
api = TestRailAPI("https://example.testrail.com/", "example@mail.com", "password", response_handler=my_handler)
new_milestone = api.milestones.add_milestone(
project_id=1,
name="New milestone",
start_on=datetime.now()
)
```
Contributing
----
Contributions are very welcome.
###### Getting started
* python 3.11
* pipenv 2022.12.19+
1. Clone the repository
```bash
git clone https://github.com/tolstislon/testrail-api.git
cd testrail-api
```
2. Install dev dependencies
```bash
pipenv install --dev
pipenv shell
```
3. Run the black
```bash
pipenv run black
```
4. Run the flake8
```bash
pipenv run flake8
```
5. Run the tests
```bash
pipenv run tests
```