• Home
  • Raw
  • Download

Lines Matching full:patch

16     MagicMock, Mock, NonCallableMagicMock, patch, _patch,
101 @patch.object(Something, 'attribute', sentinel.Patched)
107 "patch not restored")
112 patch.object('Something', 'do_something')
118 @patch.object(Something, 'attribute', None)
124 "patch not restored")
132 @patch.object(Something, 'attribute', sentinel.Patched)
133 @patch.object(Something, 'next_attribute', sentinel.Patched2)
142 "patch not restored")
144 "patch not restored")
150 @patch('%s.something' % __name__, sentinel.Something2)
163 @patch('%s.something' % __name__, sentinel.Something2)
170 "patch not restored")
172 @patch('%s.something' % __name__, sentinel.Something2)
173 @patch('%s.something_else' % __name__, sentinel.SomethingElse)
181 "patch not restored")
183 "patch not restored")
189 "patch not restored")
191 "patch not restored")
195 @patch('%s.open' % builtin_string, mock)
202 self.assertNotEqual(open, mock, "patch not restored")
206 @patch('%s.SomeClass.class_attribute' % __name__,
214 "patch not restored")
222 @patch.object(Test, 'something')
227 "patch with two arguments did not create a mock")
231 @patch.object(Test, 'something')
232 @patch.object(Test, 'something2')
243 "patch with two arguments did not create a mock")
245 "patch with two arguments did not create a mock")
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)
465 "patch not restored")
482 Foo = patch('%s.something' % __name__)(Foo)
489 "patch not restored")
491 "patch not restored")
499 @patch.object(Something, 'attribute', sentinel.Patched)
500 @patch.object(Something, 'attribute', sentinel.Patched)
507 "patch not restored")
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'})
668 # bpo-35512: Ensure that patch with a string target resolves to
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)
738 # bpo-36366: calling stop on an already stopped patch will return None.
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:
1007 with patch.object(Foo, 'static_method', autospec=True) as method:
1022 with patch.object(Foo, 'class_method', autospec=True) as method:
1030 patcher = patch('%s.function' % __name__, new=3, autospec=True)
1034 patcher = patch.object(module, 'function', new=3, autospec=True)
1042 patcher = patch(foo_name, autospec=Bar)
1053 patcher = patch(foo_name, autospec=True)
1063 patcher = patch(foo_name, autospec=True)
1076 @patch.object(Foo, 'f', object())
1090 patcher = patch(foo_name, new_callable=NonCallableMagicMock)
1103 patcher = patch.object(Foo, 'f', new_callable=NonCallableMagicMock)
1121 patcher = patch(foo_name, new_callable=Bar, arg1=1, arg2=2)
1136 patcher = patch(foo_name, new_callable=Bar, spec=Bar)
1143 patcher = patch(foo_name, new_callable=Bar, spec_set=Bar)
1153 p = patch(non_existent_attr, new_callable=NonCallableMock)
1156 p = patch(non_existent_attr, new_callable=NonCallableMock,
1167 ValueError, patch, foo_name, new=object(), new_callable=MagicMock
1170 ValueError, patch.object, Foo, 'f', new=object(),
1177 ValueError, patch, foo_name, new_callable=MagicMock,
1181 ValueError, patch.object, Foo, 'f', new_callable=MagicMock,
1196 p = patch(foo_name, new_callable=Klass, **kwargs)
1210 p = patch(foo_name, new_callable=NotAMock, spec=True)
1236 SomeTest = patch(foo_name, new_callable=SomeClass)(SomeTest)
1247 patcher1 = patch.multiple(foo_name, f=1, g=2)
1248 patcher2 = patch.multiple(Foo, f=1, g=2)
1264 @patch.multiple(foo_name, f=3, g=4)
1274 self.assertRaises(ValueError, patch.multiple, foo_name)
1275 self.assertRaises(ValueError, patch.multiple, Foo)
1283 @patch.multiple(foo_name, f=DEFAULT, g=3, foo=DEFAULT)
1301 patcher = patch.object(Foo, 'f', 3)
1304 other = patch.object(Foo, 'g', DEFAULT)
1323 @patch.multiple(foo_name, f=DEFAULT)
1324 @patch.multiple(foo_name, foo=DEFAULT)
1325 @patch(foo_name + '.g')
1329 @patch.multiple(foo_name, f=DEFAULT)
1330 @patch(foo_name + '.g')
1331 @patch.multiple(foo_name, foo=DEFAULT)
1335 @patch(foo_name + '.g')
1336 @patch.multiple(foo_name, f=DEFAULT)
1337 @patch.multiple(foo_name, foo=DEFAULT)
1366 patcher = patch.multiple(foo_name, f=DEFAULT, g=3, foo=DEFAULT)
1407 SomeTest = patch.multiple(
1420 patcher = patch.multiple(Foo, blam='blam')
1423 patcher = patch.multiple(Foo, blam='blam', create=True)
1436 patcher = patch.multiple(Foo, foo=DEFAULT, spec_set=['a', 'b'])
1453 patcher = patch.multiple(
1471 @patch.object(Foo, 'g', 1)
1472 @patch.object(Foo, 'missing', 1)
1473 @patch.object(Foo, 'f', 1)
1476 @patch.object(Foo, 'missing', 1)
1477 @patch.object(Foo, 'g', 1)
1478 @patch.object(Foo, 'f', 1)
1481 @patch.object(Foo, 'g', 1)
1482 @patch.object(Foo, 'f', 1)
1483 @patch.object(Foo, 'missing', 1)
1500 @patch.object(Foo, 'g', 1)
1501 @patch.object(Foo, 'foo', new_callable=crasher)
1502 @patch.object(Foo, 'f', 1)
1505 @patch.object(Foo, 'foo', new_callable=crasher)
1506 @patch.object(Foo, 'g', 1)
1507 @patch.object(Foo, 'f', 1)
1510 @patch.object(Foo, 'g', 1)
1511 @patch.object(Foo, 'f', 1)
1512 @patch.object(Foo, 'foo', new_callable=crasher)
1526 patcher = patch.object(Foo, 'f', 1)
1529 good = patch.object(Foo, 'g', 1)
1532 bad = patch.object(Foo, 'missing', 1)
1554 patcher = patch.object(Foo, 'f', 1)
1557 good = patch.object(Foo, 'g', 1)
1560 bad = patch.object(Foo, 'foo', new_callable=crasher)
1578 @patch.multiple(foo, fish='nearly gone')
1586 @patch('unittest.mock.patch.TEST_PREFIX', 'foo')
1600 Foo = patch.object(Foo, 'thing', 'changed')(Foo)
1609 @patch('unittest.mock.patch.TEST_PREFIX', 'bar')
1622 Foo = patch.dict(the_dict, key='changed')(Foo)
1633 p = patch('%s.SomeClass' % __name__, **{arg: True})
1647 with patch('unittest.test.testmock.support', autospec=True) as m:
1657 p = patch('%s.SomeClass' % __name__, **{arg: True})
1683 p1 = patch('squizz.squozz')
1691 p1 = patch('squizz.squozz')
1733 p = patch('%s.doesnotexist' % __name__, create=True,
1739 p = patch(MODNAME, create=True, **{kwarg: True})
1747 p = patch(MODNAME, autospec=0, **{kwarg: 0})
1752 p = patch(MODNAME, spec_set=0, **{kwarg: 0})
1757 p = patch(MODNAME, spec=0, **{kwarg: 0})
1763 p = patch(MODNAME, spec=False, spec_set=False, autospec=False)
1775 p = patch(MODNAME, **{kwarg: 0})
1785 p = patch(MODNAME, spec_set=True, **{kwarg: True})
1797 p = patch(MODNAME, spec=spec)
1807 p = patch(MODNAME, spec=spec)
1819 patch('os.unlink', something).start()
1820 patch('os.chdir', something_else).start()
1822 @patch('os.path')
1824 patch.stopall()
1845 patch.stopall()
1856 patch.dict(dic1, {1: 'I', 2: 'II'}).start()
1857 patch.dict(dic2, {2: 'b'}).start()
1859 @patch.dict(dic3)
1868 patch.stopall()
1883 patch('os.unlink', something).start()
1884 patch('os.chdir', something_else).start()
1885 patch.dict(dic1, {1: 'I', 2: 'II'}).start()
1886 patch.dict(dic2).start()
1893 patch.stopall()
1904 with patch.object(foo, '__defaults__', (1, )):
1909 with patch.object(foo, '__doc__', "FUN"):
1913 with patch.object(foo, '__module__', "testpatch2"):
1917 with patch.object(foo, '__annotations__', dict([('s', 1, )])):
1923 with patch.object(foo, '__kwdefaults__', dict([('x', 1, )])):
1936 with patch.dict(foo, OrderedDict(update_values)):
1941 with patch.dict(foo, update_values):
1952 with patch.dict('sys.modules'):
1958 # now make sure we can patch based on a dotted path:
1959 @patch('unittest.test.testmock.support.X')
1972 patch(target)
1976 @patch('unittest.test.testmock.support.X', new=object(), x=1)