### Install TestRail API Python Wrapper Source: https://github.com/tolstislon/testrail-api/blob/master/README.md Instructions for installing the `testrail-api` Python package using pip, the standard Python package installer. ```bash pip install testrail-api ``` -------------------------------- ### Install Development Dependencies for TestRail API Source: https://github.com/tolstislon/testrail-api/blob/master/README.md Commands to install development dependencies using `pipenv` and activate the project's virtual environment, preparing the development setup. ```bash pipenv install --dev pipenv shell ``` -------------------------------- ### Basic TestRail API Usage Example in Python Source: https://github.com/tolstislon/testrail-api/blob/master/README.md Demonstrates how to initialize the TestRail API client and perform common operations such as adding a milestone, creating a test run, adding a test result, attaching a file, and closing a run and milestone. ```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) ``` -------------------------------- ### Configure TestRail API with Environment Variables Source: https://github.com/tolstislon/testrail-api/blob/master/README.md Example of environment variables that can be set to configure the TestRail API client, including the TestRail instance URL, user email, and password. ```dotenv TESTRAIL_URL=https://example.testrail.com/ TESTRAIL_EMAIL=example@mail.com TESTRAIL_PASSWORD=password ``` -------------------------------- ### Run Flake8 Linter for TestRail API Source: https://github.com/tolstislon/testrail-api/blob/master/README.md Command to run `flake8`, a Python linter, to check for style guide violations and potential errors in the codebase. ```bash pipenv run flake8 ``` -------------------------------- ### Run Tests for TestRail API Project Source: https://github.com/tolstislon/testrail-api/blob/master/README.md Command to execute the project's test suite, verifying the functionality and correctness of the `testrail-api` wrapper. ```bash pipenv run tests ``` -------------------------------- ### Clone TestRail API Repository for Contribution Source: https://github.com/tolstislon/testrail-api/blob/master/README.md Commands to clone the `testrail-api` GitHub repository and navigate into its directory, serving as the first step for local development and contributions. ```bash git clone https://github.com/tolstislon/testrail-api.git cd testrail-api ``` -------------------------------- ### Run Black Formatter for TestRail API Source: https://github.com/tolstislon/testrail-api/blob/master/README.md Command to execute the `black` code formatter, ensuring consistent code style across the project. ```bash pipenv run black ``` -------------------------------- ### Implement Custom Response Handler for TestRail API Source: https://github.com/tolstislon/testrail-api/blob/master/README.md Illustrates how to define and integrate a custom response handler function with the TestRail API client. This allows for custom processing of API responses, such as error handling or specific data parsing. ```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() ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.