diff options
-rw-r--r-- | oslotest/mock_fixture.py | 2 | ||||
-rw-r--r-- | oslotest/tests/unit/test_mock_fixture.py | 10 |
2 files changed, 9 insertions, 3 deletions
diff --git a/oslotest/mock_fixture.py b/oslotest/mock_fixture.py index fb9d008..ba53dd8 100644 --- a/oslotest/mock_fixture.py +++ b/oslotest/mock_fixture.py @@ -106,7 +106,7 @@ class MockAutospecFixture(fixtures.Fixture): # patch both external and internal usage of Mock / MagicMock. self.useFixture(fixtures.MonkeyPatch('mock.Mock', _AutospecMock)) self.useFixture(fixtures.MonkeyPatch('mock.mock.Mock', _AutospecMock)) - self.useFixture(fixtures.MonkeyPatch('mock.mock.MagicMock', + self.useFixture(fixtures.MonkeyPatch('mock.MagicMock', _AutospecMagicMock)) self.useFixture(fixtures.MonkeyPatch('mock.mock.MagicMock', _AutospecMagicMock)) diff --git a/oslotest/tests/unit/test_mock_fixture.py b/oslotest/tests/unit/test_mock_fixture.py index 73afe8b..c5175b7 100644 --- a/oslotest/tests/unit/test_mock_fixture.py +++ b/oslotest/tests/unit/test_mock_fixture.py @@ -70,11 +70,17 @@ class MockSanityTestCase(testtools.TestCase): # assert that AttributeError is raised if the method does not exist. self.assertRaises(AttributeError, getattr, foo, 'lish') - def test_mock_autospec_all_members(self): + def _check_mock_autospec_all_members(self, mock_cls): for spec in [Foo, Foo()]: - foo = mock.Mock(autospec=spec) + foo = mock_cls(autospec=spec) self._check_autospeced_foo(foo) + def test_mock_autospec_all_members(self): + self._check_mock_autospec_all_members(mock.Mock) + + def test_magic_mock_autospec_all_members(self): + self._check_mock_autospec_all_members(mock.MagicMock) + @mock.patch.object(Foo, 'static_bar') @mock.patch.object(Foo, 'classic_bar') @mock.patch.object(Foo, 'bar') |