Lines Matching refs:spec
128 mock = Mock(spec=X)
129 self.assertIn(" spec='X' ", repr(mock))
131 mock = Mock(spec=X())
132 self.assertIn(" spec='X' ", repr(mock))
140 mock = Mock(spec=X, name='foo')
141 self.assertIn(" spec='X' ", repr(mock))
145 self.assertNotIn("spec", repr(mock))
148 self.assertNotIn("spec", repr(mock))
150 mock = Mock(spec=['foo'])
151 self.assertNotIn("spec", repr(mock))
215 "Cannot autospec attr 'B' from target <MagicMock spec='A'"):
224 "Cannot spec attr 'B' as the spec "):
225 mock.patch.object(A, 'B', spec=A.B).start()
227 "Cannot spec attr 'B' as the spec_set "):
230 "Cannot spec attr 'B' as the spec_set "):
232 with self.assertRaisesRegex(InvalidSpecError, "Cannot spec a Mock object."):
240 spec = ["something"]
241 mock = Mock(name="child", parent=parent, spec=spec)
255 self.assertEqual(mock._mock_methods, spec,
402 mock = Mock(spec=f)
409 # Expected call doesn't match the spec's signature
423 mock = Mock(spec=Something().meth)
425 mock = Mock(spec=Something.cmeth)
427 mock = Mock(spec=Something().cmeth)
429 mock = Mock(spec=Something.smeth)
431 mock = Mock(spec=Something().smeth)
478 mock = Mock(spec=f)
485 # Expected call doesn't match the spec's signature
563 for spec in ['something'], ('something',):
564 for arg in 'spec', 'spec_set':
565 mock = Mock(**{arg: spec})
598 test_attributes(Mock(spec=Something))
599 test_attributes(Mock(spec=Something()))
845 mock = Mock(spec=Sub(['foo']))
856 mock = Mock(spec=X)
859 mock = Mock(spec=X())
876 mock = Mock(spec=X)
879 mock = Mock(spec=X())
896 mock = Mock(spec=X)
974 mock = Mock(spec=unittest.TestCase)
978 # all attributes from the spec are included
1497 mock = Mock(spec=f)
1528 mock = Mock(spec=f)
1581 mock = Mock(spec=f)
1591 # Expected call doesn't match the spec's signature
1637 msg = "is not a valid assertion. Use a spec for the mock"
1664 m = Mock(spec=Foo)
1780 klasses.append(lambda K=Klass: K(spec=Anything))
1818 # *then* setting a spec doesn't work. Not the intended use case
2217 obj = mock(spec=Something)
2226 with unittest.mock.patch.object(obj, 'obj_with_bool_func', spec=object): pass