Created
August 30, 2018 23:06
-
-
Save rebx/de66de83abdd37c88b731f42e083adab to your computer and use it in GitHub Desktop.
creating a mock stack in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mock_stack(func): | |
@mock.patch.object(FooObject, 'method') | |
@mock.patch('some.module') | |
@functools.wraps(func) | |
def wrapped_func(*args, **kwargs): | |
return func(*args, **kwargs) | |
return wrapped_func | |
class TestSomething(unittest.TestCase): | |
@mock_stack | |
def test_some_method(self, mock_module, mock_foo_method): | |
pass | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment