add a note about how a lightweight but more powerful function-mocker could be done

(compared to standard mock).
This commit is contained in:
holger krekel 2013-08-09 10:22:49 +02:00
parent 88aa8f5435
commit 654212d93b
1 changed files with 18 additions and 0 deletions

View File

@ -1,5 +1,23 @@
recorder = monkeypatch.function(".......")
-------------------------------------------------------------
tags: nice feature
Like monkeypatch.replace but sets a mock-like call recorder:
recorder = monkeypatch.function("os.path.abspath")
recorder.set_return("/hello")
os.path.abspath("hello")
call, = recorder.calls
assert call.args.path == "hello"
assert call.returned == "/hello"
...
Unlike mock, "args.path" acts on the parsed auto-spec'ed ``os.path.abspath``
so it's independent from if the client side called "os.path.abspath(path=...)"
or "os.path.abspath('positional')".
refine parametrize API refine parametrize API
------------------------------------------------------------- -------------------------------------------------------------
tags: critical feature tags: critical feature