• Home
  • Raw
  • Download

Lines Matching full:foo

45 class Foo(object):  class
52 foo = 'bar' variable in Foo
58 foo_name = '%s.Foo' % __name__
61 def function(a, b=Foo):
414 class Foo(object): class
419 @patch.object(Foo, 'woot', staticmethod(lambda: sentinel.Patched))
421 self.assertEqual(Foo.woot(), sentinel.Patched)
424 self.assertEqual(Foo.woot(), sentinel.Static)
428 foo = sentinel.Foo
429 @patch.object(sentinel, 'Foo', 'Foo')
431 self.assertEqual(sentinel.Foo, 'Foo')
434 self.assertEqual(sentinel.Foo, foo)
438 class Foo(object): class
439 __slots__ = ('Foo',)
441 foo = Foo()
442 foo.Foo = sentinel.Foo
444 @patch.object(foo, 'Foo', 'Foo')
446 self.assertEqual(foo.Foo, 'Foo')
449 self.assertEqual(foo.Foo, sentinel.Foo)
456 class Foo(object): class
464 Foo = patch.object(Something, 'attribute', sentinel.Patched)(Foo)
466 f = Foo()
478 class Foo(object): class
485 Foo = patch('%s.something' % __name__)(Foo)
487 f = Foo()
514 foo = {'initial': object(), 'other': 'something'}
515 original = foo.copy()
517 @patch.dict(foo)
519 foo['a'] = 3
520 del foo['initial']
521 foo['other'] = 'something else'
525 self.assertEqual(foo, original)
527 @patch.dict(foo, {'a': 'b'})
529 self.assertEqual(len(foo), 3)
530 self.assertEqual(foo['a'], 'b')
534 self.assertEqual(foo, original)
536 @patch.dict(foo, [('a', 'b')])
538 self.assertEqual(len(foo), 3)
539 self.assertEqual(foo['a'], 'b')
543 self.assertEqual(foo, original)
547 foo = Container()
548 foo['initial'] = object()
549 foo['other'] = 'something'
551 original = foo.values.copy()
553 @patch.dict(foo)
555 foo['a'] = 3
556 del foo['initial']
557 foo['other'] = 'something else'
561 self.assertEqual(foo.values, original)
563 @patch.dict(foo, {'a': 'b'})
565 self.assertEqual(len(foo.values), 3)
566 self.assertEqual(foo['a'], 'b')
570 self.assertEqual(foo.values, original)
574 foo = {'initial': object(), 'other': 'something'}
575 original = foo.copy()
577 @patch.dict(foo, clear=True)
579 self.assertEqual(foo, {})
580 foo['a'] = 3
581 foo['other'] = 'something else'
585 self.assertEqual(foo, original)
587 @patch.dict(foo, {'a': 'b'}, clear=True)
589 self.assertEqual(foo, {'a': 'b'})
593 self.assertEqual(foo, original)
595 @patch.dict(foo, [('a', 'b')], clear=True)
597 self.assertEqual(foo, {'a': 'b'})
601 self.assertEqual(foo, original)
605 foo = Container()
606 foo['initial'] = object()
607 foo['other'] = 'something'
609 original = foo.values.copy()
611 @patch.dict(foo, clear=True)
613 self.assertEqual(foo.values, {})
614 foo['a'] = 3
615 foo['other'] = 'something else'
619 self.assertEqual(foo.values, original)
621 @patch.dict(foo, {'a': 'b'}, clear=True)
623 self.assertEqual(foo.values, {'a': 'b'})
627 self.assertEqual(foo.values, original)
631 foo = {}
636 @patch.dict(foo)
644 foo = {}
646 @patch.dict(foo, {'a': 'b'})
656 self.assertEqual(foo, {})
674 self.assertEqual(support.target, {'foo': 'BAZ', 'bar': 'BAR'})
677 support.target = {'foo': 'BAZ'}
679 self.assertEqual(support.target, {'foo': 'BAZ'})
689 foo = None variable in PatchTest.test_patch_descriptor.Nothing
692 foo = {} variable in PatchTest.test_patch_descriptor.Something
694 @patch.object(Nothing, 'foo', 2)
699 @patch.object(Nothing, 'foo', 2)
704 @patch.dict(foo)
709 @patch.dict(foo)
730 MockClass.z = 'foo'
736 MockClass.z = 'foo'
741 MockClass.z = 'foo'
747 MockClass.z = 'foo'
756 instance.z = 'foo'
783 patcher = patch.object(PTModule, 'something', 'foo')
787 self.assertEqual(replaced, 'foo')
795 d = {'foo': 'bar'}
815 this.assertEqual(d, {'foo': 'bar'})
817 this.assertEqual(d, {'foo': 'bar'})
819 Test = patch.dict(d, {'foo': 'bar'}, clear=True)(Test)
841 foo = 'foo' variable in PatchTest.test_get_only_proxy.Something
843 foo = 'foo' variable in PatchTest.test_get_only_proxy.SomethingElse
848 @patch.object(proxy, 'foo', 'bar')
850 self.assertEqual(proxy.foo, 'bar')
852 self.assertEqual(proxy.foo, 'foo')
853 self.assertEqual(thing.foo, 'foo')
854 self.assertNotIn('foo', proxy.__dict__)
859 foo = 'foo' variable in PatchTest.test_get_set_delete_proxy.Something
861 foo = 'foo' variable in PatchTest.test_get_set_delete_proxy.SomethingElse
866 @patch.object(proxy, 'foo', 'bar')
868 self.assertEqual(proxy.foo, 'bar')
870 self.assertEqual(proxy.foo, 'foo')
871 self.assertEqual(thing.foo, 'foo')
872 self.assertNotIn('foo', proxy.__dict__)
876 kwargs = {'side_effect': KeyError, 'foo.bar.return_value': 33,
877 'foo': MagicMock()}
884 self.assertEqual(mock.foo.bar(), 33)
885 self.assertIsInstance(mock.foo, MagicMock)
889 kwargs = {'side_effect': KeyError, 'foo.bar.return_value': 33,
890 'foo': MagicMock()}
892 patcher = patch.object(Foo, 'f', **kwargs)
897 self.assertEqual(mock.foo.bar(), 33)
898 self.assertIsInstance(mock.foo, MagicMock)
902 original = {'foo': 'bar'}
905 patcher = patch.dict(original, foo=3, bar=4, baz=5)
909 self.assertEqual(original, dict(foo=3, bar=4, baz=5))
924 foo = 'bar' variable in PatchTest.test_autospec.Boo
946 mock.foo.lower()
947 mock.foo.lower.assert_called_with()
948 self.assertRaises(AttributeError, getattr, mock.foo, 'bar')
968 self.assertIs(mock, Foo)
974 self.assertIsNot(Foo, mock)
979 test = patch.object(module, 'Foo', autospec=True)(function)
982 self.assertIsNot(Foo, mock)
1002 self.assertRaises(AttributeError, getattr, function, 'foo')
1011 #self.assertEqual(function.abc, 'foo')
1028 class Bar(Foo):
1041 FooClass = Foo
1056 self.assertIn(" name='Foo'", repr(mock))
1057 self.assertIn(" name='Foo.f'", repr(mock.f))
1058 self.assertIn(" name='Foo()'", repr(mock(None)))
1059 self.assertIn(" name='Foo().f'", repr(mock(None).f))
1065 @patch.object(Foo, 'f', object())
1092 patcher = patch.object(Foo, 'f', new_callable=NonCallableMagicMock)
1159 ValueError, patch.object, Foo, 'f', new=object(),
1170 ValueError, patch.object, Foo, 'f', new_callable=MagicMock,
1207 self.assertEqual(m.spec, Foo)
1212 original = Foo
1216 test.assertIsNot(Foo, original)
1217 test.assertIs(Foo, mock_foo)
1218 test.assertIsInstance(Foo, SomeClass)
1228 self.assertIs(Foo, original)
1232 original_foo = Foo
1233 original_f = Foo.f
1234 original_g = Foo.g
1237 patcher2 = patch.multiple(Foo, f=1, g=2)
1242 self.assertIs(Foo, original_foo)
1243 self.assertEqual(Foo.f, 1)
1244 self.assertEqual(Foo.g, 2)
1248 self.assertIs(Foo, original_foo)
1249 self.assertEqual(Foo.f, original_f)
1250 self.assertEqual(Foo.g, original_g)
1255 self.assertIs(Foo, original_foo)
1256 self.assertEqual(Foo.f, 3)
1257 self.assertEqual(Foo.g, 4)
1264 self.assertRaises(ValueError, patch.multiple, Foo)
1268 original_foo = Foo
1269 original_f = Foo.f
1270 original_g = Foo.g
1272 @patch.multiple(foo_name, f=DEFAULT, g=3, foo=DEFAULT)
1273 def test(f, foo): argument
1274 self.assertIs(Foo, original_foo)
1275 self.assertIs(Foo.f, f)
1276 self.assertEqual(Foo.g, 3)
1277 self.assertIs(Foo.foo, foo)
1279 self.assertTrue(is_instance(foo, MagicMock))
1282 self.assertEqual(Foo.f, original_f)
1283 self.assertEqual(Foo.g, original_g)
1288 original_f = Foo.f
1289 original_g = Foo.g
1291 patcher = patch.object(Foo, 'f', 3)
1294 other = patch.object(Foo, 'g', DEFAULT)
1300 self.assertIs(Foo.g, g)
1301 self.assertEqual(Foo.f, 3)
1304 self.assertEqual(Foo.f, original_f)
1305 self.assertEqual(Foo.g, original_g)
1309 original_foo = Foo
1310 original_f = Foo.f
1311 original_g = Foo.g
1314 @patch.multiple(foo_name, foo=DEFAULT)
1321 @patch.multiple(foo_name, foo=DEFAULT)
1327 @patch.multiple(foo_name, foo=DEFAULT)
1333 foo = kwargs.pop('foo')
1336 self.assertIs(Foo, original_foo)
1337 self.assertIs(Foo.f, f)
1338 self.assertIs(Foo.g, g)
1339 self.assertIs(Foo.foo, foo)
1342 self.assertTrue(is_instance(foo, MagicMock))
1347 self.assertEqual(Foo.f, original_f)
1348 self.assertEqual(Foo.g, original_g)
1352 original_foo = Foo
1353 original_f = Foo.f
1354 original_g = Foo.g
1356 patcher = patch.multiple(foo_name, f=DEFAULT, g=3, foo=DEFAULT)
1361 foo = result['foo']
1362 self.assertEqual(set(result), set(['f', 'foo']))
1364 self.assertIs(Foo, original_foo)
1365 self.assertIs(Foo.f, f)
1366 self.assertIs(Foo.foo, foo)
1368 self.assertTrue(is_instance(foo, MagicMock))
1372 self.assertEqual(Foo.f, original_f)
1373 self.assertEqual(Foo.g, original_g)
1378 original_foo = Foo
1379 original_f = Foo.f
1380 original_g = Foo.g
1384 def _test(self, f, foo): argument
1385 test.assertIs(Foo, original_foo)
1386 test.assertIs(Foo.f, f)
1387 test.assertEqual(Foo.g, 3)
1388 test.assertIs(Foo.foo, foo)
1390 test.assertTrue(is_instance(foo, MagicMock))
1392 def test_two(self, f, foo): argument
1393 self._test(f, foo)
1394 def test_one(self, f, foo): argument
1395 self._test(f, foo)
1398 foo_name, f=DEFAULT, g=3, foo=DEFAULT
1405 self.assertEqual(Foo.f, original_f)
1406 self.assertEqual(Foo.g, original_g)
1410 patcher = patch.multiple(Foo, blam='blam')
1413 patcher = patch.multiple(Foo, blam='blam', create=True)
1416 self.assertEqual(Foo.blam, 'blam')
1420 self.assertFalse(hasattr(Foo, 'blam'))
1426 patcher = patch.multiple(Foo, foo=DEFAULT, spec_set=['a', 'b'])
1429 self.assertEqual(Foo.foo, result['foo'])
1430 Foo.foo.a(1)
1431 Foo.foo.b(2)
1432 Foo.foo.a.assert_called_with(1)
1433 Foo.foo.b.assert_called_with(2)
1434 self.assertRaises(AttributeError, setattr, Foo.foo, 'c', None)
1444 Foo, f=DEFAULT, g=DEFAULT, new_callable=Thing
1448 self.assertIs(Foo.f, result['f'])
1449 self.assertIs(Foo.g, result['g'])
1450 self.assertIsInstance(Foo.f, Thing)
1451 self.assertIsInstance(Foo.g, Thing)
1452 self.assertIsNot(Foo.f, Foo.g)
1458 original_f = Foo.f
1459 original_g = Foo.g
1461 @patch.object(Foo, 'g', 1)
1462 @patch.object(Foo, 'missing', 1)
1463 @patch.object(Foo, 'f', 1)
1467 @patch.object(Foo, 'missing', 1)
1468 @patch.object(Foo, 'g', 1)
1469 @patch.object(Foo, 'f', 1)
1473 @patch.object(Foo, 'g', 1)
1474 @patch.object(Foo, 'f', 1)
1475 @patch.object(Foo, 'missing', 1)
1481 self.assertEqual(Foo.f, original_f)
1482 self.assertEqual(Foo.g, original_g)
1486 original_f = Foo.f
1487 original_g = Foo.g
1488 original_foo = Foo.foo
1493 @patch.object(Foo, 'g', 1)
1494 @patch.object(Foo, 'foo', new_callable=crasher)
1495 @patch.object(Foo, 'f', 1)
1499 @patch.object(Foo, 'foo', new_callable=crasher)
1500 @patch.object(Foo, 'g', 1)
1501 @patch.object(Foo, 'f', 1)
1505 @patch.object(Foo, 'g', 1)
1506 @patch.object(Foo, 'f', 1)
1507 @patch.object(Foo, 'foo', new_callable=crasher)
1513 self.assertEqual(Foo.f, original_f)
1514 self.assertEqual(Foo.g, original_g)
1515 self.assertEqual(Foo.foo, original_foo)
1519 original_f = Foo.f
1520 original_g = Foo.g
1522 patcher = patch.object(Foo, 'f', 1)
1525 good = patch.object(Foo, 'g', 1)
1528 bad = patch.object(Foo, 'missing', 1)
1539 self.assertEqual(Foo.f, original_f)
1540 self.assertEqual(Foo.g, original_g)
1544 original_f = Foo.f
1545 original_g = Foo.g
1546 original_foo = Foo.foo
1551 patcher = patch.object(Foo, 'f', 1)
1554 good = patch.object(Foo, 'g', 1)
1557 bad = patch.object(Foo, 'foo', new_callable=crasher)
1558 bad.attribute_name = 'foo'
1568 self.assertEqual(Foo.f, original_f)
1569 self.assertEqual(Foo.g, original_g)
1570 self.assertEqual(Foo.foo, original_foo)
1574 Foo = type('Foo', (str,), {'fish': 'tasty'})
1575 foo = Foo()
1576 @patch.multiple(foo, fish='nearly gone')
1578 self.assertEqual(foo.fish, 'nearly gone')
1581 self.assertEqual(foo.fish, 'tasty')
1584 @patch('unittest.mock.patch.TEST_PREFIX', 'foo')
1586 class Foo(object): class
1598 Foo = patch.object(Foo, 'thing', 'changed')(Foo)
1600 foo = Foo()
1601 self.assertEqual(foo.foo_one(), 'changed')
1602 self.assertEqual(foo.foo_two(), 'changed')
1603 self.assertEqual(foo.test_one(), 'original')
1604 self.assertEqual(foo.test_two(), 'original')
1609 class Foo(object): class
1620 Foo = patch.dict(the_dict, key='changed')(Foo)
1622 foo =Foo()
1623 self.assertEqual(foo.bar_one(), {'key': 'changed'})
1624 self.assertEqual(foo.bar_two(), {'key': 'changed'})
1625 self.assertEqual(foo.test_one(), {'key': 'original'})
1626 self.assertEqual(foo.test_two(), {'key': 'original'})
1804 spec = ('foo', 'bar')
1849 def foo(x=0): function
1852 with patch.object(foo, '__defaults__', (1, )):
1853 self.assertEqual(foo(), 1)
1854 self.assertEqual(foo(), 0)
1856 with patch.object(foo, '__doc__', "FUN"):
1857 self.assertEqual(foo.__doc__, "FUN")
1858 self.assertEqual(foo.__doc__, "TEST")
1860 with patch.object(foo, '__module__', "testpatch2"):
1861 self.assertEqual(foo.__module__, "testpatch2")
1862 self.assertEqual(foo.__module__, 'unittest.test.testmock.testpatch')
1864 with patch.object(foo, '__annotations__', dict([('s', 1, )])):
1865 self.assertEqual(foo.__annotations__, dict([('s', 1, )]))
1866 self.assertEqual(foo.__annotations__, dict())
1868 def foo(*a, x=0): function
1870 with patch.object(foo, '__kwdefaults__', dict([('x', 1, )])):
1871 self.assertEqual(foo(), 1)
1872 self.assertEqual(foo(), 0)