From: Karl O. Pinc Date: Mon, 31 Aug 2020 20:23:38 +0000 (-0500) Subject: Add wraps keyword to make_mock_fixture() X-Git-Url: https://papio.biology.duke.edu/gitweb/?a=commitdiff_plain;h=f6a026d95284bcbf90a2c537a3935087eaab4dc8;p=pgwui_develop Add wraps keyword to make_mock_fixture() --- diff --git a/src/pgwui_testing/testing.py b/src/pgwui_testing/testing.py index 92f8c3d..23cad3b 100644 --- a/src/pgwui_testing/testing.py +++ b/src/pgwui_testing/testing.py @@ -77,14 +77,14 @@ def pgwui_check_settings_entry_point(): # Mock support -def make_mock_fixture(module, method, autouse=False): +def make_mock_fixture(module, method, autouse=False, wraps=None): '''Returns a pytest fixture that mocks a module's method or a class's class method. "module" is a module or a class, but method is a string. ''' @fixture(autouse=autouse) def fix(monkeypatch): mocked = mock.Mock( - spec=getattr(module, method), name=method) + spec=getattr(module, method), name=method, wraps=wraps) monkeypatch.setattr(module, method, mocked) return mocked return fix