Home | History | Annotate | Download | only in pymock

Lines Matching refs:patch

19     'patch',
1164 if not attr.startswith(patch.TEST_PREFIX):
1248 """Perform the patch."""
1374 """Undo the patch."""
1395 """Activate a patch, returning any created mock."""
1402 """Stop an active patch."""
1412 raise TypeError("Need a valid target to patch. You supplied: %r" %
1424 patch.object(target, attribute, new=DEFAULT, spec=None, create=False,
1427 patch the named member (`attribute`) on an object (`target`) with a mock
1430 `patch.object` can be used as a decorator, class decorator or a context
1432 `autospec` and `new_callable` have the same meaning as for `patch`. Like
1433 `patch`, `patch.object` takes arbitrary keyword arguments for configuring
1436 When used as a class decorator `patch.object` honours `patch.TEST_PREFIX`
1452 with patch.multiple(settings, FIRST_PATCH='one', SECOND_PATCH='two'):
1455 Use `DEFAULT` as the value if you want `patch.multiple` to create
1457 function by keyword, and a dictionary is returned when `patch.multiple` is
1460 `patch.multiple` can be used as a decorator, class decorator or a context
1462 `autospec` and `new_callable` have the same meaning as for `patch`. These
1463 arguments will be applied to *all* patches done by `patch.multiple`.
1465 When used as a class decorator `patch.multiple` honours `patch.TEST_PREFIX`
1475 'Must supply at least one keyword argument with patch.multiple'
1495 def patch(
1500 `patch` acts as a function decorator, class decorator or a context
1503 the patch is undone.
1506 `MagicMock`. If `patch` is used as a decorator and `new` is
1508 decorated function. If `patch` is used as a context manager the created
1514 calling `patch` from. The target is imported when the decorated function
1518 if patch is creating one for you.
1521 patch
1538 By default `patch` will fail to replace attributes that don't exist. If
1539 you pass in `create=True`, and the attribute doesn't exist, patch will
1546 Patch can be used as a `TestCase` class decorator. It works by
1548 code when your test methods share a common patchings set. `patch` finds
1549 tests by looking for method names that start with `patch.TEST_PREFIX`.
1551 You can specify an alternative prefix by setting `patch.TEST_PREFIX`.
1553 Patch can be used as a context manager, with the with statement. Here the
1556 "as"; very useful if `patch` is creating a mock object for you.
1558 `patch` takes arbitrary keyword arguments. These will be passed to
1561 `patch.dict(...)`, `patch.multiple(...)` and `patch.object(...)` are
1573 Patch a dictionary, or dictionary like object, and restore the dictionary
1589 `patch.dict` can also be called with arbitrary keyword arguments to set
1592 with patch.dict('sys.modules', mymodule=Mock(), other_module=Mock()):
1595 `patch.dict` can be used as a context manager, decorator or class
1596 decorator. When used as a class decorator `patch.dict` honours
1597 `patch.TEST_PREFIX` for choosing which methods to wrap.
1628 if (attr.startswith(patch.TEST_PREFIX) and
1637 """Patch the dict."""
1700 for patch in list(_patch._active_patches):
1701 patch.stop()
1704 patch.object = _patch_object
1705 patch.dict = _patch_dict
1706 patch.multiple = _patch_multiple
1707 patch.stopall = _patch_stopall
1708 patch.TEST_PREFIX = 'test'