mock.__class__

Here are the examples of the python api mock.__class__ taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

3 Source : testmock.py
with GNU General Public License v3.0
from guohuadeng

    def test_class_assignable(self):
        for mock in Mock(), MagicMock():
            self.assertNotIsInstance(mock, int)

            mock.__class__ = int
            self.assertIsInstance(mock, int)
            mock.foo


    @unittest.expectedFailure

0 Source : testmock.py
with GNU General Public License v3.0
from guohuadeng

    def test_spec_class(self):
        class X(object):
            pass

        mock = Mock(spec=X)
        self.assertIsInstance(mock, X)

        mock = Mock(spec=X())
        self.assertIsInstance(mock, X)

        self.assertIs(mock.__class__, X)
        self.assertEqual(Mock().__class__.__name__, 'Mock')

        mock = Mock(spec_set=X)
        self.assertIsInstance(mock, X)

        mock = Mock(spec_set=X())
        self.assertIsInstance(mock, X)


    def test_setting_attribute_with_spec_set(self):