This is a Python wrapper of the TestRail API(v2) according to the official documentation
pip install testrail-api
TESTRAIL_URL
TESTRAIL_EMAIL
TESTRAIL_PASSWORD
from datetime import datetime
from testrail_api import TestRailAPI
api = TestRailAPI("https://example.testrail.com/", "[email protected]", "password")
# if use environment variables
# api = TestRailAPI()
new_milestone = api.milestones.add_milestone(
project_id=1,
name="New milestone",
start_on=int(datetime.now().timestamp())
)
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 = "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)
Contributions are very welcome.