Lines Matching full:patch
15 MagicMock, Mock, NonCallableMagicMock, patch, _patch,
99 @patch.object(Something, 'attribute', sentinel.Patched)
105 "patch not restored")
112 @patch.object(Something, 'attribute', None)
118 "patch not restored")
126 @patch.object(Something, 'attribute', sentinel.Patched)
127 @patch.object(Something, 'next_attribute', sentinel.Patched2)
136 "patch not restored")
138 "patch not restored")
144 @patch('%s.something' % __name__, sentinel.Something2)
157 @patch('%s.something' % __name__, sentinel.Something2)
164 "patch not restored")
166 @patch('%s.something' % __name__, sentinel.Something2)
167 @patch('%s.something_else' % __name__, sentinel.SomethingElse)
175 "patch not restored")
177 "patch not restored")
183 "patch not restored")
185 "patch not restored")
189 @patch('%s.open' % builtin_string, mock)
196 self.assertNotEqual(open, mock, "patch not restored")
200 @patch('%s.SomeClass.class_attribute' % __name__,
208 "patch not restored")
216 @patch.object(Test, 'something')
221 "patch with two arguments did not create a mock")
225 @patch.object(Test, 'something')
226 @patch.object(Test, 'something2')
237 "patch with two arguments did not create a mock")
239 "patch with two arguments did not create a mock")
254 @patch('%s.SomeClass' % __name__, spec=SomeClass)
264 @patch.object(SomeClass, 'class_attribute', spec=SomeClass)
276 @patch('%s.SomeClass' % __name__, spec=['wibble'])
286 @patch.object(SomeClass, 'class_attribute', spec=['wibble'])
299 @patch('%s.open' % builtin_string)
300 @patch('%s.SomeClass' % __name__, spec=['wibble'])
309 @patch('%s.SomeClass' % __name__, spec=True)
321 @patch.object(PTModule, 'SomeClass', spec=True)
333 @patch('%s.SomeClass' % __name__, spec=True)
347 @patch('%s.frooble' % builtin_string, sentinel.Frooble, create=True)
356 @patch.object(SomeClass, 'frooble', sentinel.Frooble, create=True)
366 @patch('%s.frooble' % builtin_string, sentinel.Frooble)
381 @patch.object(SomeClass, 'ord', sentinel.Frooble)
394 @patch(__name__+'.ord')
399 @patch(__name__+'.open')
419 @patch.object(Foo, 'woot', staticmethod(lambda: sentinel.Patched))
429 @patch.object(sentinel, 'Foo', 'Foo')
444 @patch.object(foo, 'Foo', 'Foo')
464 Foo = patch.object(Something, 'attribute', sentinel.Patched)(Foo)
471 "patch not restored")
485 Foo = patch('%s.something' % __name__)(Foo)
492 "patch not restored")
494 "patch not restored")
502 @patch.object(Something, 'attribute', sentinel.Patched)
503 @patch.object(Something, 'attribute', sentinel.Patched)
510 "patch not restored")
517 @patch.dict(foo)
527 @patch.dict(foo, {'a': 'b'})
536 @patch.dict(foo, [('a', 'b')])
553 @patch.dict(foo)
563 @patch.dict(foo, {'a': 'b'})
577 @patch.dict(foo, clear=True)
587 @patch.dict(foo, {'a': 'b'}, clear=True)
595 @patch.dict(foo, [('a', 'b')], clear=True)
611 @patch.dict(foo, clear=True)
621 @patch.dict(foo, {'a': 'b'}, clear=True)
633 @patch('%s.SomeClass' % __name__, object())
634 @patch('%s.SomeClass' % __name__, object(), autospec=True)
635 @patch.object(SomeClass, object())
636 @patch.dict(foo)
646 @patch.dict(foo, {'a': 'b'})
660 @patch.dict('os.environ', {'konrad_delong': 'some value'})
668 # bpo-35512: Ensure that patch with a string target resolves to
672 @patch.dict('unittest.test.testmock.support.target', {'bar': 'BAR'})
694 @patch.object(Nothing, 'foo', 2)
699 @patch.object(Nothing, 'foo', 2)
704 @patch.dict(foo)
709 @patch.dict(foo)
728 @patch('%s.SomeClass' % __name__, spec=SomeClass, spec_set=True)
734 @patch.object(support, 'SomeClass', spec=SomeClass, spec_set=True)
739 @patch('%s.SomeClass' % __name__, spec_set=True)
745 @patch.object(support, 'SomeClass', spec_set=True)
753 @patch('%s.SomeClass' % __name__, spec_set=True)
763 patcher = patch('%s.something' % __name__)
775 patcher = patch(foo_name, 'bar', 3)
783 patcher = patch.object(PTModule, 'something', 'foo')
797 patcher = patch.dict(d, [('spam', 'eggs')], clear=True)
819 Test = patch.dict(d, {'foo': 'bar'}, clear=True)(Test)
848 @patch.object(proxy, 'foo', 'bar')
866 @patch.object(proxy, 'foo', 'bar')
879 patcher = patch(foo_name, **kwargs)
892 patcher = patch.object(Foo, 'f', **kwargs)
905 patcher = patch.dict(original, foo=3, bar=4, baz=5)
971 test = patch(foo_name, autospec=True)(function)
979 test = patch.object(module, 'Foo', autospec=True)(function)
988 @patch('%s.function' % __name__, autospec=True)
1008 @patch('%s.function' % __name__, autospec=True,
1019 patcher = patch('%s.function' % __name__, new=3, autospec=True)
1023 patcher = patch.object(module, 'function', new=3, autospec=True)
1031 patcher = patch(foo_name, autospec=Bar)
1042 patcher = patch(foo_name, autospec=True)
1052 patcher = patch(foo_name, autospec=True)
1065 @patch.object(Foo, 'f', object())
1079 patcher = patch(foo_name, new_callable=NonCallableMagicMock)
1092 patcher = patch.object(Foo, 'f', new_callable=NonCallableMagicMock)
1110 patcher = patch(foo_name, new_callable=Bar, arg1=1, arg2=2)
1125 patcher = patch(foo_name, new_callable=Bar, spec=Bar)
1132 patcher = patch(foo_name, new_callable=Bar, spec_set=Bar)
1142 p = patch(non_existent_attr, new_callable=NonCallableMock)
1145 p = patch(non_existent_attr, new_callable=NonCallableMock,
1156 ValueError, patch, foo_name, new=object(), new_callable=MagicMock
1159 ValueError, patch.object, Foo, 'f', new=object(),
1166 ValueError, patch, foo_name, new_callable=MagicMock,
1170 ValueError, patch.object, Foo, 'f', new_callable=MagicMock,
1185 p = patch(foo_name, new_callable=Klass, **kwargs)
1199 p = patch(foo_name, new_callable=NotAMock, spec=True)
1225 SomeTest = patch(foo_name, new_callable=SomeClass)(SomeTest)
1236 patcher1 = patch.multiple(foo_name, f=1, g=2)
1237 patcher2 = patch.multiple(Foo, f=1, g=2)
1253 @patch.multiple(foo_name, f=3, g=4)
1263 self.assertRaises(ValueError, patch.multiple, foo_name)
1264 self.assertRaises(ValueError, patch.multiple, Foo)
1272 @patch.multiple(foo_name, f=DEFAULT, g=3, foo=DEFAULT)
1291 patcher = patch.object(Foo, 'f', 3)
1294 other = patch.object(Foo, 'g', DEFAULT)
1313 @patch.multiple(foo_name, f=DEFAULT)
1314 @patch.multiple(foo_name, foo=DEFAULT)
1315 @patch(foo_name + '.g')
1319 @patch.multiple(foo_name, f=DEFAULT)
1320 @patch(foo_name + '.g')
1321 @patch.multiple(foo_name, foo=DEFAULT)
1325 @patch(foo_name + '.g')
1326 @patch.multiple(foo_name, f=DEFAULT)
1327 @patch.multiple(foo_name, foo=DEFAULT)
1356 patcher = patch.multiple(foo_name, f=DEFAULT, g=3, foo=DEFAULT)
1397 SomeTest = patch.multiple(
1410 patcher = patch.multiple(Foo, blam='blam')
1413 patcher = patch.multiple(Foo, blam='blam', create=True)
1426 patcher = patch.multiple(Foo, foo=DEFAULT, spec_set=['a', 'b'])
1443 patcher = patch.multiple(
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)
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)
1522 patcher = patch.object(Foo, 'f', 1)
1525 good = patch.object(Foo, 'g', 1)
1528 bad = patch.object(Foo, 'missing', 1)
1551 patcher = patch.object(Foo, 'f', 1)
1554 good = patch.object(Foo, 'g', 1)
1557 bad = patch.object(Foo, 'foo', new_callable=crasher)
1576 @patch.multiple(foo, fish='nearly gone')
1584 @patch('unittest.mock.patch.TEST_PREFIX', 'foo')
1598 Foo = patch.object(Foo, 'thing', 'changed')(Foo)
1607 @patch('unittest.mock.patch.TEST_PREFIX', 'bar')
1620 Foo = patch.dict(the_dict, key='changed')(Foo)
1631 p = patch('%s.SomeClass' % __name__, **{arg: True})
1645 with patch('unittest.test.testmock.support', autospec=True) as m:
1655 p = patch('%s.SomeClass' % __name__, **{arg: True})
1681 p1 = patch('squizz.squozz')
1689 p1 = patch('squizz.squozz')
1731 p = patch('%s.doesnotexist' % __name__, create=True,
1737 p = patch(MODNAME, create=True, **{kwarg: True})
1745 p = patch(MODNAME, autospec=0, **{kwarg: 0})
1750 p = patch(MODNAME, spec_set=0, **{kwarg: 0})
1755 p = patch(MODNAME, spec=0, **{kwarg: 0})
1761 p = patch(MODNAME, spec=False, spec_set=False, autospec=False)
1773 p = patch(MODNAME, **{kwarg: 0})
1783 p = patch(MODNAME, spec_set=True, **{kwarg: True})
1795 p = patch(MODNAME, spec=spec)
1805 p = patch(MODNAME, spec=spec)
1817 patch('os.unlink', something).start()
1818 patch('os.chdir', something_else).start()
1820 @patch('os.path')
1822 patch.stopall()
1843 patch.stopall()
1852 with patch.object(foo, '__defaults__', (1, )):
1856 with patch.object(foo, '__doc__', "FUN"):
1860 with patch.object(foo, '__module__', "testpatch2"):
1864 with patch.object(foo, '__annotations__', dict([('s', 1, )])):
1870 with patch.object(foo, '__kwdefaults__', dict([('x', 1, )])):