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

huh?

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):
        self.True != 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 recommended 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.5.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

strongmock-0.0.5-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: strongmock-0.0.5.tar.gz
  • Upload date:
  • Size: 6.4 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.5.tar.gz
Algorithm Hash digest
SHA256 9306eaecfc9b064a104f39c60ded708093b8e11cd7de8a07597ec6ab0c64afc6
MD5 8803e5f05304ead7f3e8ab54527ac100
BLAKE2b-256 080445a40d5b511f9cf66bf48e21c94281656f2dec0a8d17ef59cb27acbda57b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: strongmock-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 5.6 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 3ea5a8d4d5b51aa4e4c07b580dba16d4c0bd23062cd2bd165424f32fa316d16b
MD5 9df71bca9ef297e32396dfa145817776
BLAKE2b-256 6ef4e414670c04aaad301cfa579659229afae94c8744832c4871ae3dea622784

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