2.0.0a6
Pre-release
Pre-release
-
Extend
captorto be used as a rest matcherE.g., support
args = captor() when(freud).says(*args).thenReturn("Yes.") assert freud.says("Are", "you", "dreaming?") == "Yes." assert args.value == ("Are", "you", "dreaming?") # or kwargs = captor() when(freud).does(**kwargs).thenReturn(False) -
Added
call_captorcall = call_captor() when(mock).do(call).thenReturn("ok") mock.do(1, 2, x=3) assert call.value == ((1, 2), {"x": 3}) -
Added
patch_attrandpatch_dictfor non-callable monkeypatch-style use cases
(e.g.sys.stdout,sys.argv, and environment/config dictionaries) with
context-manager support and restoration throughunstub.E.g.
patch_attr("sys.argv", ["foo", "bar"]) with patch_attr("sys.stdout", StringIO()) as stdout: ... with patch_dict(os.environ, {"user": "bob"}): ... -
Added explicit partial-
unstubtargeting by host + attribute name.
This complements method-reference partial unstub (e.g.unstub(cat.meow))
and supports tuple form and shorthand form, including multiple attributes
in one call.E.g.
unstub(cat.meow) unstub((cat, "meow")) unstub(cat, "meow") unstub((cat, "meow"), (os.path, "exists")) -
Also implemented
unstub("os.path")