Skip to content

MockContext cannot be reused #441

@SwampFalc

Description

@SwampFalc

I was trying out the MockContext in order to test some code I've written.

However, it seems that a MockContext can only be used once, which makes it useless when you have a task that makes more than one Call.

Here's a quick shell session showing the error:

>>> import invoke
>>> mc = invoke.MockContext(run=invoke.Result('success'))
>>> mc.run('one')
<invoke.runners.Result object at 0x7faedea3acd0>
>>> mc.run('two')
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    mc.run('two')
  File "/usr/local/lib/python2.7/dist-packages/invoke/context.py", line 243, in run
    return self._yield_result('_run', command)
  File "/usr/local/lib/python2.7/dist-packages/invoke/context.py", line 236, in _yield_result
    raise_from(NotImplementedError, None)
  File "/usr/local/lib/python2.7/dist-packages/invoke/vendor/six.py", line 718, in raise_from
    raise value
NotImplementedError

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions