Lines Matching refs:patch
16 MagicMock, Mock, NonCallableMagicMock, patch, _patch,
101 @patch.object(Something, 'attribute', sentinel.Patched)
112 patch.object('Something', 'do_something')
118 @patch.object(Something, 'attribute', None)
132 @patch.object(Something, 'attribute', sentinel.Patched)
133 @patch.object(Something, 'next_attribute', sentinel.Patched2)
150 @patch('%s.something' % __name__, sentinel.Something2)
163 @patch('%s.something' % __name__, sentinel.Something2)
172 @patch('%s.something' % __name__, sentinel.Something2)
173 @patch('%s.something_else' % __name__, sentinel.SomethingElse)
195 @patch('%s.open' % builtin_string, mock)
206 @patch('%s.SomeClass.class_attribute' % __name__,
222 @patch.object(Test, 'something')
231 @patch.object(Test, 'something')
232 @patch.object(Test, 'something2')
260 @patch('%s.SomeClass' % __name__, spec=SomeClass)
270 @patch.object(SomeClass, 'class_attribute', spec=SomeClass)
282 @patch('%s.SomeClass' % __name__, spec=['wibble'])
292 @patch.object(SomeClass, 'class_attribute', spec=['wibble'])
305 @patch('%s.open' % builtin_string)
306 @patch('%s.SomeClass' % __name__, spec=['wibble'])
315 @patch('%s.SomeClass' % __name__, spec=True)
327 @patch.object(PTModule, 'SomeClass', spec=True)
339 @patch('%s.SomeClass' % __name__, spec=True)
353 @patch('%s.frooble' % builtin_string, sentinel.Frooble, create=True)
362 @patch.object(SomeClass, 'frooble', sentinel.Frooble, create=True)
372 @patch('%s.frooble' % builtin_string, sentinel.Frooble)
381 @patch.object(SomeClass, 'ord', sentinel.Frooble)
388 @patch(__name__+'.ord')
393 @patch(__name__+'.open')
413 @patch.object(Foo, 'woot', staticmethod(lambda: sentinel.Patched))
423 @patch.object(sentinel, 'Foo', 'Foo')
438 @patch.object(foo, 'Foo', 'Foo')
458 Foo = patch.object(Something, 'attribute', sentinel.Patched)(Foo)
482 Foo = patch('%s.something' % __name__)(Foo)
499 @patch.object(Something, 'attribute', sentinel.Patched)
500 @patch.object(Something, 'attribute', sentinel.Patched)
514 @patch.dict(foo)
524 @patch.dict(foo, {'a': 'b'})
533 @patch.dict(foo, [('a', 'b')])
550 @patch.dict(foo)
560 @patch.dict(foo, {'a': 'b'})
574 @patch.dict(foo, clear=True)
584 @patch.dict(foo, {'a': 'b'}, clear=True)
592 @patch.dict(foo, [('a', 'b')], clear=True)
608 @patch.dict(foo, clear=True)
618 @patch.dict(foo, {'a': 'b'}, clear=True)
629 with patch.dict(foo, a='c') as patched:
637 @patch('%s.SomeClass' % __name__, object())
638 @patch('%s.SomeClass' % __name__, object(), autospec=True)
639 @patch.object(SomeClass, object())
640 @patch.dict(foo)
649 @patch.dict(foo, {'a': 'b'})
660 @patch.dict('os.environ', {'konrad_delong': 'some value'})
672 @patch.dict('unittest.test.testmock.support.target', {'bar': 'BAR'})
685 @patch('%s.SomeClass' % __name__, spec=SomeClass, spec_set=True)
691 @patch.object(support, 'SomeClass', spec=SomeClass, spec_set=True)
696 @patch('%s.SomeClass' % __name__, spec_set=True)
702 @patch.object(support, 'SomeClass', spec_set=True)
710 @patch('%s.SomeClass' % __name__, spec_set=True)
720 patcher = patch('%s.something' % __name__)
733 patcher = patch(foo_name, 'bar', 3)
739 patcher = patch(foo_name, 'bar', 3)
748 patcher = patch.object(PTModule, 'something', 'foo')
762 patcher = patch.dict(d, [('spam', 'eggs')], clear=True)
776 patcher = patch.dict(d, [('spam', 'eggs')], clear=True)
792 Test = patch.dict(d, {'foo': 'bar'}, clear=True)(Test)
821 @patch.object(proxy, 'foo', 'bar')
839 @patch.object(proxy, 'foo', 'bar')
852 patcher = patch(foo_name, **kwargs)
865 patcher = patch.object(Foo, 'f', **kwargs)
878 patcher = patch.dict(original, foo=3, bar=4, baz=5)
940 test = patch(foo_name, autospec=True)(function)
948 test = patch.object(module, 'Foo', autospec=True)(function)
957 @patch('%s.function' % __name__, autospec=True)
977 @patch('%s.function' % __name__, autospec=True,
988 with patch('%s.Foo.static_method' % __name__, autospec=True) as method:
994 with patch('%s.Foo.class_method' % __name__, autospec=True) as method:
1000 patcher = patch('%s.function' % __name__, new=3, autospec=True)
1004 patcher = patch.object(module, 'function', new=3, autospec=True)
1012 patcher = patch(foo_name, autospec=Bar)
1023 patcher = patch(foo_name, autospec=True)
1033 patcher = patch(foo_name, autospec=True)
1046 @patch.object(Foo, 'f', object())
1060 patcher = patch(foo_name, new_callable=NonCallableMagicMock)
1073 patcher = patch.object(Foo, 'f', new_callable=NonCallableMagicMock)
1091 patcher = patch(foo_name, new_callable=Bar, arg1=1, arg2=2)
1106 patcher = patch(foo_name, new_callable=Bar, spec=Bar)
1113 patcher = patch(foo_name, new_callable=Bar, spec_set=Bar)
1123 p = patch(non_existent_attr, new_callable=NonCallableMock)
1126 p = patch(non_existent_attr, new_callable=NonCallableMock,
1137 ValueError, patch, foo_name, new=object(), new_callable=MagicMock
1140 ValueError, patch.object, Foo, 'f', new=object(),
1147 ValueError, patch, foo_name, new_callable=MagicMock,
1151 ValueError, patch.object, Foo, 'f', new_callable=MagicMock,
1166 p = patch(foo_name, new_callable=Klass, **kwargs)
1180 p = patch(foo_name, new_callable=NotAMock, spec=True)
1206 SomeTest = patch(foo_name, new_callable=SomeClass)(SomeTest)
1217 patcher1 = patch.multiple(foo_name, f=1, g=2)
1218 patcher2 = patch.multiple(Foo, f=1, g=2)
1234 @patch.multiple(foo_name, f=3, g=4)
1244 self.assertRaises(ValueError, patch.multiple, foo_name)
1245 self.assertRaises(ValueError, patch.multiple, Foo)
1253 @patch.multiple(foo_name, f=DEFAULT, g=3, foo=DEFAULT)
1271 patcher = patch.object(Foo, 'f', 3)
1274 other = patch.object(Foo, 'g', DEFAULT)
1293 @patch.multiple(foo_name, f=DEFAULT)
1294 @patch.multiple(foo_name, foo=DEFAULT)
1295 @patch(foo_name + '.g')
1299 @patch.multiple(foo_name, f=DEFAULT)
1300 @patch(foo_name + '.g')
1301 @patch.multiple(foo_name, foo=DEFAULT)
1305 @patch(foo_name + '.g')
1306 @patch.multiple(foo_name, f=DEFAULT)
1307 @patch.multiple(foo_name, foo=DEFAULT)
1336 patcher = patch.multiple(foo_name, f=DEFAULT, g=3, foo=DEFAULT)
1377 SomeTest = patch.multiple(
1390 patcher = patch.multiple(Foo, blam='blam')
1393 patcher = patch.multiple(Foo, blam='blam', create=True)
1406 patcher = patch.multiple(Foo, foo=DEFAULT, spec_set=['a', 'b'])
1423 patcher = patch.multiple(
1441 @patch.object(Foo, 'g', 1)
1442 @patch.object(Foo, 'missing', 1)
1443 @patch.object(Foo, 'f', 1)
1446 @patch.object(Foo, 'missing', 1)
1447 @patch.object(Foo, 'g', 1)
1448 @patch.object(Foo, 'f', 1)
1451 @patch.object(Foo, 'g', 1)
1452 @patch.object(Foo, 'f', 1)
1453 @patch.object(Foo, 'missing', 1)
1470 @patch.object(Foo, 'g', 1)
1471 @patch.object(Foo, 'foo', new_callable=crasher)
1472 @patch.object(Foo, 'f', 1)
1475 @patch.object(Foo, 'foo', new_callable=crasher)
1476 @patch.object(Foo, 'g', 1)
1477 @patch.object(Foo, 'f', 1)
1480 @patch.object(Foo, 'g', 1)
1481 @patch.object(Foo, 'f', 1)
1482 @patch.object(Foo, 'foo', new_callable=crasher)
1496 patcher = patch.object(Foo, 'f', 1)
1499 good = patch.object(Foo, 'g', 1)
1502 bad = patch.object(Foo, 'missing', 1)
1524 patcher = patch.object(Foo, 'f', 1)
1527 good = patch.object(Foo, 'g', 1)
1530 bad = patch.object(Foo, 'foo', new_callable=crasher)
1548 @patch.multiple(foo, fish='nearly gone')
1556 @patch('unittest.mock.patch.TEST_PREFIX', 'foo')
1570 Foo = patch.object(Foo, 'thing', 'changed')(Foo)
1579 @patch('unittest.mock.patch.TEST_PREFIX', 'bar')
1592 Foo = patch.dict(the_dict, key='changed')(Foo)
1603 p = patch('%s.SomeClass' % __name__, **{arg: True})
1617 with patch('unittest.test.testmock.support', autospec=True) as m:
1627 p = patch('%s.SomeClass' % __name__, **{arg: True})
1653 p1 = patch('squizz.squozz')
1661 p1 = patch('squizz.squozz')
1703 p = patch('%s.doesnotexist' % __name__, create=True,
1709 p = patch(MODNAME, create=True, **{kwarg: True})
1717 p = patch(MODNAME, autospec=0, **{kwarg: 0})
1722 p = patch(MODNAME, spec_set=0, **{kwarg: 0})
1727 p = patch(MODNAME, spec=0, **{kwarg: 0})
1733 p = patch(MODNAME, spec=False, spec_set=False, autospec=False)
1745 p = patch(MODNAME, **{kwarg: 0})
1755 p = patch(MODNAME, spec_set=True, **{kwarg: True})
1767 p = patch(MODNAME, spec=spec)
1777 p = patch(MODNAME, spec=spec)
1789 patch('os.unlink', something).start()
1790 patch('os.chdir', something_else).start()
1792 @patch('os.path')
1794 patch.stopall()
1815 patch.stopall()
1826 patch.dict(dic1, {1: 'I', 2: 'II'}).start()
1827 patch.dict(dic2, {2: 'b'}).start()
1829 @patch.dict(dic3)
1838 patch.stopall()
1853 patch('os.unlink', something).start()
1854 patch('os.chdir', something_else).start()
1855 patch.dict(dic1, {1: 'I', 2: 'II'}).start()
1856 patch.dict(dic2).start()
1863 patch.stopall()
1874 with patch.object(foo, '__defaults__', (1, )):
1878 with patch.object(foo, '__doc__', "FUN"):
1882 with patch.object(foo, '__module__', "testpatch2"):
1886 with patch.object(foo, '__annotations__', dict([('s', 1, )])):
1892 with patch.object(foo, '__kwdefaults__', dict([('x', 1, )])):
1905 with patch.dict(foo, OrderedDict(update_values)):
1910 with patch.dict(foo, update_values):
1921 with patch.dict('sys.modules'):
1928 @patch('unittest.test.testmock.support.X')
1936 patch('')
1940 @patch('unittest.test.testmock.support.X', new=object(), x=1)