{"id":16018329,"url":"https://github.com/jupe/pytest-lockable","last_synced_at":"2025-03-17T20:31:46.677Z","repository":{"id":43477946,"uuid":"271354149","full_name":"jupe/pytest-lockable","owner":"jupe","description":"pytest plugin for lockable resources","archived":false,"fork":false,"pushed_at":"2024-01-24T12:24:26.000Z","size":89,"stargazers_count":1,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-09-21T09:05:41.920Z","etag":null,"topics":["pytest","pytest-plugin","python3","resource-allocation","resource-management"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jupe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-10T18:26:50.000Z","updated_at":"2021-11-09T12:31:14.000Z","dependencies_parsed_at":"2024-10-08T16:42:07.237Z","dependency_job_id":"61d20eee-fe01-4a27-ae9a-beabda87106c","html_url":"https://github.com/jupe/pytest-lockable","commit_stats":{"total_commits":32,"total_committers":4,"mean_commits":8.0,"dds":0.1875,"last_synced_commit":"cf8bfca18d2128e369f6b9a11b7ef9222f17f6e8"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupe%2Fpytest-lockable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupe%2Fpytest-lockable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupe%2Fpytest-lockable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupe%2Fpytest-lockable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jupe","download_url":"https://codeload.github.com/jupe/pytest-lockable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243885864,"owners_count":20363642,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pytest","pytest-plugin","python3","resource-allocation","resource-management"],"created_at":"2024-10-08T16:41:57.708Z","updated_at":"2025-03-17T20:31:46.339Z","avatar_url":"https://github.com/jupe.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pytest-lockable\n\n[![CircleCI](https://circleci.com/gh/jupe/pytest-lockable/tree/master.svg?style=svg)](https://circleci.com/gh/jupe/pytest-lockable/tree/master)\n[![PyPI version](https://badge.fury.io/py/pytest-lockable.svg)](https://pypi.org/project/pytest-lockable/)\n[![Coverage Status](https://coveralls.io/repos/github/jupe/pytest-lockable/badge.svg)](https://coveralls.io/github/jupe/pytest-lockable)\n\npytest plugin for lockable resources.\n\nReplacement for Jenkins lockable -plugin.\nLocking is implemented using `\u003cresource-id\u003e.pid` files and is released automatically.\n\nResources are automatically released when pytest ends.\n\nResources are described in json file as array of objects. Each object has some mandatory fields but can contains any other as well. Required fields are: `id`, `online`, `hostname`.\n\n## Example `resources.json`\n\n```\n[\n  {\n    \"id\": \"1234\",\n    \"online\": true,\n    \"hostname\": \"localhost\",\n    \"os\": \"Android\"\n  }\n]\n```\n\n`id` should be unique for each resources. `online` describes if resource are available for allocator. Set this `false`  if you don't want to allocate resource. `hostname` is used to select suitable resource by running host. \n\nUsage:\n```\npytest --allocation_hostname localhost -s --allocation_requirements os=Android my_test\n```\n\n\n## installation\n\n**Requires:** python 3.7\u003c\n\n```python\npip install pytest-lockable\n```\n\n\n## integrations\n\npytest-lockable integrates pytest-metadata - when resource is \nreserved and [pytest-metadata](https://github.com/pytest-dev/pytest-metadata) plugin are in use metadata will \nbe generated from resource json with  `resource_` -prefixes.\ne.g. `resource_id=\u003cid\u003e`. \nSame dictionary are also recorded to testsuite property using\n[record_testsuite_property](https://docs.pytest.org/en/stable/reference.html#record-testsuite-property) -method.\n\n## Usage\n\nCustom options:\n\n```\n--allocation_hostname=\u003chostname\u003e, default=\u003cos-hostname\u003e  Allocation host\n--allocation_requirements=\u003crequirements\u003e                 Resource requirements to be allocate\n--allocation_timeout=\u003ctimeout\u003e, default=10               Allocation timeout in seconds\n--allocation_resource_list_file=\u003cfilename\u003e, default=resources.json \n                                                         Available resorces list\n--allocation_lock_folder=\u003cfolder\u003e, default=\u003cos-tmp-path\u003e allocation lockfiles folder\n```\n\n*`\u003crequirements\u003e`* can be json-string or key-value pairs. requirements have to match available resources to make allocation possible. Key-value pairs example: `key=value\u0026key2=value2` \n\nExample:\n\nUse shared lockable resource\n``` python\ndef test_example(lockable_resource):\n    \"\"\" Simple test \"\"\"\n    print(f'Testing with resource: {lockable_resource}')\n```\n\nAllocate lockable resource during test with given requirements\n``` python\ndef test_example(lockable):\n    \"\"\" Simple test \"\"\"\n    with lockable.auto_lock({\"my\": \"requirements\"}) as allocation:\n        print(f'Testing with resource#: {allocation.resource_id}')\n```\n\nSee [example test](example/test_example.py). Usage:\n```\ncd example\npytest --allocation_hostname localhost -s --allocation_lock_folder . .\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjupe%2Fpytest-lockable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjupe%2Fpytest-lockable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjupe%2Fpytest-lockable/lists"}