Exemplo n.º 1
0
    def test_pipeline_is_locked_before_execution(self):
        def zfunc():
            return 0

        p = Pipeline([zfunc])
        with self.assertRaises(UnlockedPipelineError) as context:
            p.push()
Exemplo n.º 2
0
    def test_pipeline_push_with_args(self):
        def sum1(x):
            return x + 1

        p = Pipeline([sum1])
        p.lock()
        result = p.push(0)
        assert result == 1

        p = Pipeline([sum1, sum1, sum1])
        p.lock()
        result = p.push(0)
        assert result == 3
Exemplo n.º 3
0
    def test_pipeline_push_no_args(self):
        def zero():
            return 0

        def one():
            return 1

        p = Pipeline([zero])
        p.lock()
        result = p.push()
        assert result == 0

        p = Pipeline([zero, one])
        p.lock()
        result = p.push()
        assert result == 1
Exemplo n.º 4
0
    def test_pipeline_push_no_args_no_return(self):
        def void():
            pass

        p = Pipeline([void])
        p.lock()
        result = p.push()
        assert result is None
Exemplo n.º 5
0
    def test_pipeline_push_with_object(self):
        class Anything():
            def __init__(self):
                pass

            def __call__(self):
                return 42

        p = Pipeline([Anything()])
        p.lock()
        result = p.push()
        assert result is 42