Skip to main content

pytest-minio-mock

Pip Stats

PyPI version Downloads linting: pylint

Overview

pytest-minio-mock is a pytest plugin designed to simplify testing of applications that interact with Minio the code S3 compatible object storage system. It is not designed to test the correnction to the minio server. It provides a fixture that mocks the minio.Minio class, allowing for easy testing of Minio interactions without the need for a real Minio server.

The plugin supports python version 3.8 or above.

Features

  • Mock implementation of the minio.Minio client.

  • Easy to use pytest fixture.

  • Supports versioning.

  • Currently the plugin mocks the following Minio client APIs:

    Bucket Operations:

    • make_bucket
    • list_buckets
    • bucket_exists
    • remove_bucket
    • list_objects
    • get_bucket_versioning
    • set_bucket_versioning

    Objects Operations:

    • get_object
    • fget_object
    • put_object
    • fput_object
    • stat_object
    • remove_object
    • get_presigned_url
    • presigned_put_object
    • presigned_get_object

Installation

To install pytest-minio-mock, run:

pip install pytest-minio-mock

Usage

To use the minio_mock fixture in your pytest tests, simply include it as a parameter in your test functions. Then use minio.Minio() as usual Here's an example:

def foo():
    try:
        minio_client = minio.Minio(
            endpoint=S3_URI,
            access_key=S3_ACCESS_KEY,
            secret_key=S3_SECRET_KEY,
            region=S3_REGION
        )
        return minio_client.make_bucket("buckets")
    except Exception as e:
        logging.error(e)


def test_file_upload(minio_mock):
    # Calling function foo that involves using minio.Minio()
    assert foo()
    minio_client = minio.Minio(
            endpoint=S3_URI,
            access_key=S3_ACCESS_KEY,
            secret_key=S3_SECRET_KEY,
            region=S3_REGION
        )
    buckets = minio.list_buckets()
    assert len(buckets)==1

The minio_mock fixture will patch newly created minio.Minio() thus providing you with a way to test your code around the Minio client easily.

At the moment, instances of minio.Minio() created before loading the minio_mock fixture code will not be patched. This might be an issue if one or more of the fixtures you are using in your tests that preceeds minio_mock in the parameters list of the test function, initiates instances of minio.Minio() that you want to test. As a workaround make sure that minio_mock is the first fixture in the list of arguments of function where minio_mock is needed. Example:

@pytest.fixture()
def system_under_test(minio_mock: MockMinioClient, storage_provider_stub: StorageProvider):
    # your code here
    pass

API

MockMinioClient

A brief description of the mocked methods and their behavior, like:

  • make_bucket(bucket_name, ...) # Mocks bucket creation.
  • fput_object(bucket_name, object_name, file_path, ...) # Mocks file upload.
  • ...

Contributing

Contributions to pytest-minio-mock are welcome!

Follow the usual path:

  • fork the repository
  • create a feature branch
  • push the branch to your forked repository
  • from the forked repository, create a "pull request" to this project.

When creating a pull request make sure to use the following template:

Change Summary
 - item one
 - item two
Related issue number
 - issue a
 - issue b
Checklist
  [ ] code is ready
  [ ] add tests
  [ ] all tests passing
  [ ] test coverage did not drop
  [ ] PR is ready for review

After a pull request has been submitted:

  • A reviewer must review the pull-request
  • the pull requests must pass all tests for all supported python versions 3.8, 3.9, 3.10, 3.11 and 3.12.
  • A maintainer will eventually merges the pull request
  • A release manager will upload it to pypi.

License

pytest-minio-mock is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for pytest-minio-mock 0.4.19

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-minio-mock 0.4.19
File Size Uploaded
pytest_minio_mock-0.4.19.tar.gz 19.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-minio-mock 0.4.19
File Interpreter ABI Platform
pytest_minio_mock-0.4.19-py3-none-any.whl Python 3 none any Details

Total release size: 33.0 kB

Release files / pytest_minio_mock-0.4.19.tar.gz

Download URL pytest_minio_mock-0.4.19.tar.gz
Size 19.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b8dabd09dd4a4dc5970bd57155a32b1161f88a48d0aac38ab9b95c39029e1d09
BLAKE2b-256 checksum
How to use checksums
851cd504ee8c7af4b08df1dcebf450e7a55d74efc1bf89f1e9d5488491a34a16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 6, 2025.

Transparency log

Release files / pytest_minio_mock-0.4.19-py3-none-any.whl

Download URL pytest_minio_mock-0.4.19-py3-none-any.whl
Size 14.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d93567670a01acfe2e2f8f4d056e64686eb14b622682702058dd53e71eba62c7
BLAKE2b-256 checksum
How to use checksums
7122da64288b3891d7b0394fcb322a8c0f04504eebbe58019c18f1ea0edc7075
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 6, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.19 This release

2 release files

0.4.18

2 release files

0.4.16

2 release files

0.4.15

2 release files

0.4.14

2 release files

0.4.13

2 release files

0.3.13

2 release files

0.2.11

2 release files

0.2.10

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.2

2 release files

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