Exemple #1
0
    def test_basic(self):
        class Streamer(Runnable):
            def next(self, state, **runopts):
                if state.cnt <= 0:
                    raise EndOfStream
                return state.updated(cnt=state.cnt - 1)

        r = Unwind(Streamer())
        states = r.run(State(cnt=3)).result()

        # states should contain 3 states with cnt=3..0
        self.assertEqual(len(states), 3)
        for idx, state in enumerate(states):
            self.assertEqual(state.cnt, 2 - idx)
Exemple #2
0
    def test_dynamic_validation(self):
        class simo(traits.SIMO, Runnable):
            def next(self, state):
                return States(state, state)

        with self.assertRaises(StateDimensionalityError):
            Unwind(simo()).run(States()).result()
Exemple #3
0
    def test_validation(self):
        class simo(Runnable, traits.SIMO):
            def next(self, state):
                return States(state, state)

        with self.assertRaises(TypeError):
            Unwind(simo())