Created
March 26, 2014 15:55
-
-
Save hpk42/9786612 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_monkeypatch_context_processor_with_exception(monkeypatch): | |
class TerribleException(Exception): | |
pass | |
@staticmethod | |
def _func(): | |
raise TerribleException('terrible!') | |
monkeypatch.setattr(SampleNew, 'hello', _func) | |
with pytest.raises(TerribleException): | |
assert SampleNew.hello() | |
monkeypatch.undo() | |
assert SampleNew.hello() is True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment