3 ms·
If you are doing this for testing, it's already a feature of pytest: http://pytest.org/latest/monkeypatch.html http://pytest.org/latest/monkeypatch.html
by pekk 14y ago
If you are doing this for testing, it's already a feature of pytest: http://pytest.org/latest/monkeypatch.html http://pytest.org/latest/monkeypatch.html
- clarete 14y agoI 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.