def test_pipe_exception(): "How an exception in a pipe should look like" f = pipe | str | foreach(X.upper()) | foreach(~X.lower() | int) | list with pytest.raises(ValueError) as excinfo: f('adfasfa') assert excinfo.value.message == ( "invalid literal for int() with base 10: 'a'\n" " in pipe | X.lower | X() | int\n" " in pipe | str | foreach(X.upper | X()) | foreach(X.lower | X() | int) | list" )
def test_with_exception_in_foreach(self): f = foreach(unless(AttributeError, X.lower())) | list assert f(['A', 'B', 37]) == ['a', 'b', None]
def test_with_exception(self): f = unless(AttributeError, foreach(X.lower()) | list) assert f(['A', 'B', 37]) is None
def test_ok(self): f = unless(AttributeError, foreach(X.lower())) | list assert f("ABC") == ['a', 'b', 'c']
def test_with_exception(self): f = unless(AttributeError, foreach(X.lower()) | list) assert f(['A', 'B', 37]) is None
def test_ok(self): f = unless(AttributeError, foreach(X.lower())) | list assert f("ABC") == ['a', 'b', 'c']
def test_with_exception_in_foreach(self): f = foreach(unless(AttributeError, X.lower())) | list assert f(['A', 'B', 37]) == ['a', 'b', None]