Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Python Fake

🌟 Overview

This project provides a Fake class that can be used to replace any object in a test, in development environment or in any other situation where you need to replace an object with a fake one.

The tries to provide a mock implementation for any usage, including properties, items, length, iterator, return value, await value, etc so that it never fails in runtime due to a missing implementation.

On the other hand, sometimes other pieces of code expect a certain implementation and the default implementation of the Fake class is not enough. In this case, you can use the __Fake_... parameters in the constructor to provide a more specific implementation.

At the moment, it doesn't provide tools for monitoring how the object was used, but it is planned to be implemented in the future.

🔎 Sample Usage

Fakeing the picamera2 module of Raspberry Pi so that one can run the code on a non-Raspberry Pi development environment:

from fake import Fake

sys.modules['picamera2'] = Fake(
    _Fake__props={
        'Picamera2': Fake(
            _Fake__return_value=Fake(
                _Fake__props={
                    'capture_array': Fake(
                        _Fake__return_value=np.zeros((1, 1, 3), dtype=np.uint8),
                    ),
                },
            ),
        ),
    },
)

⚙️ Parameters

A Fake object can be created with the following parameters:

  • _Fake__props: A dictionary that contains the properties of the object and their respective values.
  • _Fake__items: A dictionary that contains the items of the object and their respective values.
  • _Fake__list: A list that contains the items of the object. (in case the index is a number and not listed in the __items dictionary). It also sets the length of the object if _Fake__length is not set.
  • _Fake__return_value: The return value of the object when it is called.
  • _Fake__await_value: The return value of the object when it is awaited.
  • _Fake__length: The length of the object when it is queried via the len function.
  • _Fake__iter: The iterator of the object when it is queried via the iter function.

📦 Installation

Pip

pip install python-fake

Poetry

poetry add python-fake

Metadata

Release files for python-fake 0.1.4.dev2250331103100525250

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

Source distribution (sdist)

Source distribution for python-fake 0.1.4.dev2250331103100525250
File Size Uploaded
python_fake-0.1.4.dev2250331103100525250.tar.gz 4.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-fake 0.1.4.dev2250331103100525250
File Interpreter ABI Platform
python_fake-0.1.4.dev2250331103100525250-py3-none-any.whl Python 3 none any Details

Total release size: 9.5 kB

Release files / python_fake-0.1.4.dev2250331103100525250.tar.gz

Download URL python_fake-0.1.4.dev2250331103100525250.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2001e09db60928043d7a3ba9b3062d4800a3552ee0b58dcdf1ce2cf1bb050149
BLAKE2b-256 checksum
How to use checksums
cee973a4c24a08617aa53f75f239fb4aaa2f7b9df2f5942287d984538c9d07ac
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 Mar 31, 2025.

Transparency log

Release files / python_fake-0.1.4.dev2250331103100525250-py3-none-any.whl

Download URL python_fake-0.1.4.dev2250331103100525250-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8d1c096fbcc2c051c4ca0e21f877eadd207c0b1b8d6e7fe3732add20b6c04b32
BLAKE2b-256 checksum
How to use checksums
49b07e3e379addc1fb2b50636369e0efdf8cb7ab095183fe150864f5fb4306e5
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 Mar 31, 2025.

Transparency log
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