Example #1
0
    def test_empty(self):
        """
        Empty pipe returns same value.
        """
        o = object()

        assert o is pipe()(o)
Example #2
0
    def test_success(self):
        """
        Succeeds if all wrapped converters succeed.
        """
        c = pipe(str, strtobool, bool)

        assert True is c("True") is c(True)
Example #3
0
    def test_fail(self):
        """
        Fails if any wrapped converter fails.
        """
        c = pipe(str, strtobool)

        # First wrapped converter fails:
        with pytest.raises(ValueError):
            c(33)

        # Last wrapped converter fails:
        with pytest.raises(ValueError):
            c("33")
Example #4
0
 class C(object):
     a1 = attrib(default="True", converter=pipe(str, strtobool, bool))
     a2 = attrib(default=True, converter=[str, strtobool, bool])
Example #5
0
 class C:
     a1 = attrib(default="True", converter=pipe(str, to_bool, bool))
     a2 = attrib(default=True, converter=[str, to_bool, bool])