Skip to content

Commit 7295065

Browse files
committed
Merge branch 'master' of github.com:pytest-dev/pytest-mock
2 parents 54072e4 + 2eafa5c commit 7295065

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

pytest_mock.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ class MockFixture(object):
1515
ensuring that they are uninstalled at the end of each test.
1616
"""
1717

18+
Mock = mock_module.Mock
19+
MagicMock = mock_module.MagicMock
20+
1821
def __init__(self):
1922
self._patches = [] # list of mock._patch objects
2023
self.patch = self._Patcher(self._patches)

test_pytest_mock.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
pytest_plugins = 'pytester'
77

8+
89
class UnixFS(object):
910
"""
1011
Wrapper to os functions to simulate a Unix file system, used for testing
@@ -121,3 +122,17 @@ def test_deprecated_mock(mock, tmpdir):
121122
assert os.listdir(str(tmpdir)) == ['mocked']
122123
mock.stopall()
123124
assert os.listdir(str(tmpdir)) == []
125+
126+
127+
def test_mocker_has_magic_mock_class_as_attribute_for_instantiation():
128+
from pytest_mock import mock_module, MockFixture
129+
130+
mocker = MockFixture()
131+
assert isinstance(mocker.MagicMock(), mock_module.MagicMock)
132+
133+
134+
def test_mocker_has_mock_class_as_attribute_for_instantiation():
135+
from pytest_mock import mock_module, MockFixture
136+
137+
mocker = MockFixture()
138+
assert isinstance(mocker.Mock(), mock_module.Mock)

0 commit comments

Comments
 (0)