Last active
February 3, 2019 01:25
-
-
Save ryanermita/febd438af5895f4fe2c0f15dd36bbf83 to your computer and use it in GitHub Desktop.
A simple test that demonstrate the autospec parameter in @patch decorator.
This file contains hidden or 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
import unittest | |
from unittest.mock import patch | |
class MyDummyClass: | |
def test_dummy_function(self): | |
return "hello" | |
class TestAutoSpec(unittest.TestCase): | |
@patch('test_func.MyDummyClass', autospec=True) | |
def test_autospec_true(self, mock_dummy_class): | |
print(dir(mock_dummy_class)) | |
pass | |
@patch('test_func.MyDummyClass') | |
def test_autospec_false(self, mock_dummy_class): | |
print(dir(mock_dummy_class)) | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment