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:

  • local_path

  • memory_path

  • s3_path

  • gcs_path

  • 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"], indirect=True]) # noqa: E501
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_temp_path(region_name, endpoint_url)

  • tmp_upath_factory.gcs_temp_path(endpoint_url)

  • tmp_upath_factory.azure_temp_path(connection_string)

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.0.7.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

pytest_servers-0.0.7-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file pytest-servers-0.0.7.tar.gz.

File metadata

  • Download URL: pytest-servers-0.0.7.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for pytest-servers-0.0.7.tar.gz
Algorithm Hash digest
SHA256 c9409260eaf5943e2e07368f4167ccb65c74ef2e6852fa4ab69d0034d14478d8
MD5 052b4f5e6eb446d6a2318baf90a823d3
BLAKE2b-256 f0b0a6d3132ed9fc6b2874adb6fa9e11453d8acd47917e5d310abc41923f0f7b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_servers-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 6b99d82fe27c5fe1b3ab013e562f27587d92d0c8d494cb4313684a9809de08bf
MD5 a4251deb5a8798b678ab2a84b8722773
BLAKE2b-256 d2f5fbbba0765a4ba475821c688028fc282de51fe4bb9c4483b776e0a086dd37

See more details on using hashes here.

Supported by

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