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

Async

Also works on async functions, with similar stronger patching

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

Uploaded Source

Built Distribution

strongmock-0.0.4-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: strongmock-0.0.4.tar.gz
  • Upload date:
  • Size: 5.9 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.4.tar.gz
Algorithm Hash digest
SHA256 00fbf85f811a7c4a899f93b39029b7fdf721ef2e5e2b975e372ca8b12abedefa
MD5 065501abb9d7578eca5889b12e9e0ee7
BLAKE2b-256 080b66d8f750f51c725cdd851a2b841857216728f26abcc3cdc79c5f1c7dc90b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: strongmock-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 5.3 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8b2818f4871def83c2dedb0435a4a8e29259f9cb6aaea53690a80a8760eee192
MD5 dd0744a3c96c1e0941a5be6bc7f7f2a5
BLAKE2b-256 be92410032a9fcae655e8e0651328b527cb80c757f89878bd11a362816c83a22

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