Re:Show HN: Forbidden Fruit – Patch built-in Python objects
by pekk on Wednesday April 03, 2013 @03:31PM
(#5488463)
If you are doing this for testing, it's already a feature of pytest: http://pytest.org/latest/monkeypatch.html
[ Parent
| on HN ]
Re:Show HN: Forbidden Fruit – Patch built-in Python objects
by clarete on Wednesday April 03, 2013 @03:44PM
(#5488524)
I might be wrong, but I don't think that it's actually possible to mock built-in objects (written in C, not in python) using pytest.
A very quick test would be trying to do something like this:
>>> monkeypatch(str, "blah", "bleh") >>> assert str.blah == "bleh"
I tried it here with no success though.