Skip to main content

pytest servers

Project description

pytest servers

PyPI Status Python Version License

Tests Codecov pre-commit Black

Features

Create temporary directories on the following filesystems:

Installation

You can install pytest servers via pip from PyPI:

$ pip install pytest-servers

To use temporary S3 paths:

$ pip install pytest-servers[s3]

To use temporary Azure paths

$ pip install pytest-servers[azure]

To use temporary Google Cloud Storage paths

$ pip install pytest-servers[gcs]

To install all extras:

$ pip install pytest-servers[all]

Usage

The main fixture provided by pytest-servers provides is tmp_upath_factory, which can be used to generate temporary paths on different (mocked) filesystems:

def test_something_on_s3(tmp_upath_factory):
    path = tmp_upath_factory.mktemp("s3")
    foo = path / "foo"
    foo.write_text("foo")
    ...

mktemp supports the following filesystem types:

  • local (local filesystem)

  • memory (in-memory filesystem)

  • s3 (Amazon S3)

  • gcs (Google Cloud Storage)

  • azure (Azure Storage)

Some convenience fixtures that wrap tmp_upath_factory.mktemp and return a paths on these filesystems are also available:

  • tmp_local_path

  • tmp_memory_path

  • tmp_s3_path

  • tmp_gcs_path

  • tmp_azure_path

The tmp_upath fixture can be used for parametrizing paths with pytest’s indirect parametrization:

@pytest.mark.parametrize("tmp_upath", ["local", "s3", "gcs", "gs"], indirect=True)
def test_something(tmp_upath):
    pass

In order to use real remotes instead of mocked ones, use tmp_upath_factory with the following methods

  • tmp_upath_factory.s3(region_name, client_kwargs) where client_kwargs are passed to the underlying S3FileSystem/boto client

  • tmp_upath_factory.gcs(endpoint_url)

  • tmp_upath_factory.azure(connection_string)

Versioning support can be used by using the versioning fixture. This is currently supported for s3 and gcs remotes

# using mktemp
def test_something_on_s3_versioned(tmp_upath_factory):
    path = tmp_upath_factory.mktemp("s3", version_aware=True)
    assert path.fs.version_aware # bucket has versioning enabled

# or, using remote-specific fixtures
def test_something_on_s3_versioned(tmp_s3_path, versioning):
    assert tmp_s3_path.fs.version_aware # bucket has versioning enabled

Contributing

Contributions are very welcome. To learn more, see the Contributor Guide.

License

Distributed under the terms of the Apache 2.0 license, pytest servers is free and open source software.

Issues

If you encounter any problems, please file an issue along with a detailed description.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_servers-0.5.13.tar.gz (25.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_servers-0.5.13-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file pytest_servers-0.5.13.tar.gz.

File metadata

  • Download URL: pytest_servers-0.5.13.tar.gz
  • Upload date:
  • Size: 25.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pytest_servers-0.5.13.tar.gz
Algorithm Hash digest
SHA256 1974ba15658774b1ec5d66b04511e259ba29aa693532c9be9aa97feeeb97c5e8
MD5 97cc4394991c5fb701a0ddc888f8155c
BLAKE2b-256 5e88b7addb7e60d92407294e9e0c5bc9b21581e9bf6abe859d40155b3d0521a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_servers-0.5.13.tar.gz:

Publisher: release.yml on iterative/pytest-servers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytest_servers-0.5.13-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_servers-0.5.13-py3-none-any.whl
Algorithm Hash digest
SHA256 3401046b8a051cc2e31e55df5b2a224bd3d5a48d2bc5a7669bfc78c7c908f856
MD5 055506ab04a1bbc530485a3851b272d7
BLAKE2b-256 126c7e103924225bb40a7dfcc8f3fd7ea0dd5987ef47751ecaba59644e13e394

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_servers-0.5.13-py3-none-any.whl:

Publisher: release.yml on iterative/pytest-servers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page