Skip to main content

pytest-lockable

CircleCI PyPI version Coverage Status

pytest plugin for lockable resources.

Replacement for Jenkins lockable -plugin. Locking is implemented using <resource-id>.pid files and is released automatically.

Resources are automatically released when pytest ends.

Resources 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.

Example resources.json

[
  {
    "id": "1234",
    "online": true,
    "hostname": "localhost",
    "os": "Android"
  }
]

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.

Usage:

pytest --allocation_hostname localhost -s --allocation_requirements os=Android my_test

installation

Requires: python 3.7<

pip install pytest-lockable

conftest.py:

pytest_plugins = ("lockable.plugin",)

integrations

pytest-lockable integrates pytest-metadata - when resource is reserved and pytest-metadata plugin are in use metadata will be generated from resource json with resource_ -prefixes. e.g. resource_id=<id>. Same dictionary are also recorded to testsuite property using record_testsuite_property -method.

Usage

Custom options:

--allocation_hostname=<hostname>, default=<os-hostname>  Allocation host
--allocation_requirements=<requirements>                 Resource requirements to be allocate
--allocation_timeout=<timeout>, default=10               Allocation timeout in seconds
--allocation_resource_list_file=<filename>, default=resources.json 
                                                         Available resorces list
--allocation_lock_folder=<folder>, default=<os-tmp-path> allocation lockfiles folder

<requirements> can be json-string or key-value pairs. requirements have to match available resources to make allocation possible. Key-value pairs example: key=value&key2=value2

Example:

Use shared lockable resource

def test_example(lockable_resource):
    """ Simple test """
    print(f'Testing with resource: {lockable_resource}')

Allocate lockable resource during test with given requirements

def test_example(lockable):
    """ Simple test """
    with lockable.auto_lock({"my": "requirements"}) as allocation:
        print(f'Testing with resource#: {allocation.resource_id}')

See example test. Usage:

cd example
pytest --allocation_hostname localhost -s --allocation_lock_folder . .

Metadata

Release files for pytest-lockable 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-lockable 0.7.0
File Size Uploaded Provenance Actions
pytest-lockable-0.7.0.tar.gz 12.2 kB Without provenance Details for pytest-lockable-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytest-lockable 0.7.0
File Interpreter ABI Platform Actions
pytest_lockable-0.7.0-py3-none-any.whl Python 3 none any Details for pytest_lockable-0.7.0-py3-none-any.whl

Total release size: 16.8 kB

Release files / pytest-lockable-0.7.0.tar.gz

Download URL pytest-lockable-0.7.0.tar.gz
Size 12.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5ad2127e91f4a78a4a7711e8c762b23e6b3eec45e82a40ccba05511e8feec30a
BLAKE2b-256 checksum
How to use checksums
53bcb437d2666448c240b5e9500fa3f0f6ebe2fe1ed606d1660d64421c621a66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10

Release files / pytest_lockable-0.7.0-py3-none-any.whl

Download URL pytest_lockable-0.7.0-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d34d749de4a70e20c1aa10c56b6b999725c46dc65ee4ea2993e967aa02dd2ac
BLAKE2b-256 checksum
How to use checksums
3971f26257198303b26a4eae76928dc7356b720c19bb5ef9792fccf0720ee106
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10

Security for pytest-lockable 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page