Metadata-Version: 2.1
Name: strongmock
Version: 0.0.6
Summary: 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.
Author-email: Arrman Anicket Saha <arrmansa99+430@gmail.com>
Project-URL: Homepage, https://github.com/arrmansa/strongmock
Project-URL: Bug Tracker, https://github.com/arrmansa/strongmock/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: The Unlicense (Unlicense)
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE

# 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.mock_imports`
Replaces imports with Magicmock, takes in a tuple of strings, optional parameter override which decides if we override existing imports as well (True by default).

### `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 and usage

## 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.mock_imports

We can pass testcases that need imports inside them

```python
class TestImportPatch(unittest.TestCase):
    @strongpatch.mock_imports(("somelib_abcd",))
    def test_import_somelib_abcd(self):
        import somelib_abcd
        self.assertIsInstance(somelib_abcd.somefn(), MagicMock)
```

## strongpatch.equal_basic_objects

We dump the bytes from objsrc to objdst

### huh?

Yes, you can now pass these testcases.

```python
import unittest
from strongmock import strongpatch
class StrongMockDemoTest(unittest.TestCase):
    @strongpatch.equal_basic_objects(False, True)
    def test_truefalse_patch_0(self):
        if True != False:
            raise RuntimeError("TRUEFALSE PATCH FAILED")
```

# Links
[PyPi](https://pypi.org/project/strongmock) \
[GitHub](https://github.com/arrmansa/strongmock)

# 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)](https://www.youtube.com/watch?v=uMvNQRSKccg)
