Last active
August 12, 2020 19:51
-
-
Save thepabloaguilar/980e8e6ed7df04a6ed53399dcdb4734a to your computer and use it in GitHub Desktop.
[Article] Monkey Patching is not too bad - pytest plugin example
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
from returns.result import Result, Success, Failure | |
def example_function(arg: str) -> Result[int, str]: | |
if arg.isnumeric(): | |
return Success(int(arg)) | |
return Failure('"{0}" is not a number'.format(arg)) | |
def test_if_failure_is_created_at_example_function(returns): | |
with returns.has_trace(Failure, example_function): | |
Success('not a number').bind(example_function) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment