Skip to content

SequenceDispatcher incompatible with @do #64

@rbtcollins

Description

@rbtcollins

@Do creates a function on the fly which we then can't use to match the intent in test code:

@do
def program():
    name = yield Effect(Print('What... is your quest?'))
...
    def test_print(self):
        def check_message(print_):
            self.assertEqual(["What... is your quest?"], print_.line)

        sequence = SequenceDispatcher([
            (Func(None), None),
            (Print('What... is your quest?'), check_message),
            ])

        with sequence.consume():
            sync_perform(sequence, program())

fails:

======================================================================
ERROR: 06.Tests.test_print
----------------------------------------------------------------------
Traceback (most recent call last):
  File "06.py", line 80, in test_print
    sync_perform(sequence, program())
  File "/home/robertc/.virtualenvs/effect/local/lib/python2.7/site-packages/effect/_sync.py", line 34, in sync_perform
    six.reraise(*errors[0])
  File "/home/robertc/.virtualenvs/effect/local/lib/python2.7/site-packages/effect/_base.py", line 154, in _perform
    raise NoPerformerFoundError(effect.intent)
effect._base.NoPerformerFoundError: Func(func=<function doit at 0x7f09c143b5f0>)

Pulling out the func is hard because of their being no dispatcher for perform_func

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions