MCPcopy Create free account
hub / github.com/celery/celery / patching

Function patching

t/unit/conftest.py:636–648  ·  view source on GitHub ↗

Monkeypath.setattr shortcut. Example: .. code-block:: python >>> def test_foo(patching): >>> # execv value here will be mock.MagicMock by default. >>> execv = patching('os.execv') >>> patching('sys.platform', 'darwin') # set concrete value

(monkeypatch, request)

Source from the content-addressed store, hash-verified

634
635@pytest.fixture()
636def patching(monkeypatch, request):
637 """Monkeypath.setattr shortcut.
638 Example:
639 .. code-block:: python
640 >>> def test_foo(patching):
641 >>> # execv value here will be mock.MagicMock by default.
642 >>> execv = patching('os.execv')
643 >>> patching('sys.platform', 'darwin') # set concrete value
644 >>> patching.setenv('DJANGO_SETTINGS_MODULE', 'x.settings')
645 >>> # val will be of type mock.MagicMock by default
646 >>> val = patching.setitem('path.to.dict', 'KEY')
647 """
648 return _patching(monkeypatch, request)
649
650
651@contextmanager

Callers 15

test_reload_from_cwdFunction · 0.85
preserve_encodingMethod · 0.85
test_load_averageFunction · 0.85
test_daylightMethod · 0.85
test_utcoffsetMethod · 0.85
test_on_blockingFunction · 0.85
test_blockdetectionFunction · 0.85
test_sample_memFunction · 0.85

Calls 1

_patchingClass · 0.85

Tested by

no test coverage detected