Ejemplo n.º 1
0
 def test_it_can_stub_an_attr_from_an_obj(self):
     o = Foobar(1, 2, 3)
     s = stub_attr(o, 'a')
     s.replace()
     self.assertIs(o.a, s.value)
     self.assertTrue(isinstance(s.value, Mock))
     s.restore()
     self.assertIsNot(o.a, s)
Ejemplo n.º 2
0
 def test_it_can_stub_an_attr_from_an_obj_using_with(self):
     o = Foobar(1, 2, 3)
     with stub_attr(o, 'a') as s:
         self.assertIs(o.a, s)
         self.assertTrue(isinstance(s, Mock))
     self.assertIsNot(o.a, s)