Skip to main content

StrongMock is a powerful mocking library for Python that leverages low-level ctypes functionality to provide extensive mocking capabilities. Some care may be needed while using this.

Project description

StrongMock

Ever wanted Unlimited Power while patching things ?

StrongMock is a powerful mocking library for Python that leverages low-level ctypes functionality to provide extensive mocking capabilities. Some care may be needed while using this.

Functionality/Usage

Basic

instead of unittest.mock.patch use strongmock.strongpatch

More advanced features

strongpatch.equal_basic_objects

Can make floats / ints / True False and other basic objects equal to each other.
This customization of the equality behavior of basic objects can be useful when you have to test very very specific edge cases, maybe something governing program flow etc.

strongpatch.object

Same as patch.object, but does the same advanced replacement as strongpatch

strongpatch.multiple

Same as patch.multiple, but does the same advanced replacement as strongpatch

Safety

Some care has been taken to avoid crashes and breakage, but the user does have full control. One word answer - no.

Working

strongpatch

This applies when the target of a strongmock.strongpatch is a function defined in python with a __code__ attribute. For other cases (methods in a class, classes, lbrary functions in c, etc.), the behaviour is the same as unittest.patch.
This will patch the __code__ attribute of the function to call the mock, meaning that references will also have the functionality of mock.
This can be extremely convenient in some cases.

strongpatch.equal_basic_objects

We dump the bytes from objsrc to objdst

What??!

Yes, you can now pass these testcases.

import unittest
from strongmock import strongpatch
class StrongMockDemoTest(unittest.TestCase):
    @strongpatch.equal_basic_objects(True, False)
    def test_true_and_false_are_equal(self):
        if True != False:
            raise RuntimeError("true is equal to false")

Links

PyPi
GitHub

License

StrongMock is licensed under the Unlicense. See the LICENSE file for details.

Official theme music

When using these methods, it is reccomended that you listen to this for better code.
Kai's Theme Epic Version (Slowed + BassBoosted)

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

strongmock-0.0.3.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

strongmock-0.0.3-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file strongmock-0.0.3.tar.gz.

File metadata

  • Download URL: strongmock-0.0.3.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.7

File hashes

Hashes for strongmock-0.0.3.tar.gz
Algorithm Hash digest
SHA256 4ad68548392dbb9903e2d10136b8f1e7f79a03ecf2d1e131ab61c166a48d1698
MD5 4bc27f50b8e1392e14b13074182b4afa
BLAKE2b-256 5970cad3ad2948f9349c4ed2f861361f2d330ad8c79fd7b5724da5da01beb6d9

See more details on using hashes here.

File details

Details for the file strongmock-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: strongmock-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.7

File hashes

Hashes for strongmock-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bc234ea6509ddcc94ec3c7f149032ad6ec3d0eb4a63b84f950fe243b92c99e23
MD5 b3ca4b9e19ca3ef832048b86e4cf8af1
BLAKE2b-256 264f282fdff7109173b2d92b1c87ff2bcce6bf185fd5af54560cecf690522855

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