MCPcopy
hub / github.com/celery/celery / patching

Function patching

t/unit/conftest.py:615–627  ·  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

613
614@pytest.fixture()
615def patching(monkeypatch, request):
616 """Monkeypath.setattr shortcut.
617 Example:
618 .. code-block:: python
619 >>> def test_foo(patching):
620 >>> # execv value here will be mock.MagicMock by default.
621 >>> execv = patching('os.execv')
622 >>> patching('sys.platform', 'darwin') # set concrete value
623 >>> patching.setenv('DJANGO_SETTINGS_MODULE', 'x.settings')
624 >>> # val will be of type mock.MagicMock by default
625 >>> val = patching.setitem('path.to.dict', 'KEY')
626 """
627 return _patching(monkeypatch, request)
628
629
630@contextmanager

Callers 15

test_close_open_fdsFunction · 0.85
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
test_mem_rssFunction · 0.85
test_psFunction · 0.85

Calls 1

_patchingClass · 0.85

Tested by

no test coverage detected