from spec import Spec
from mock import patch

from invoke.context import Context


class Context_(Spec):
    class run_:
        @patch('invoke.context.run')
        def honors_warn_state(self, run):
            Context(run={'warn': True}).run('x')
            run.assert_called_with('x', warn=True)

from spec import Spec
from mock import patch

from invoke.context import Context


class Context_(Spec):
    class run_:
        def _honors(self, kwarg, value):
            with patch('invoke.context.run') as run:
                Context(run={kwarg: value}).run('x')
                run.assert_called_with('x', **{kwarg: value})

        def honors_warn_state(self):
            self._honors('warn', True)

        def honors_hide_state(self):
            self._honors('hide', 'both')

Refactor + add test for run(hide)
Refactor + add test for run(hide)

  from spec import Spec
  from mock import patch
  
  from invoke.context import Context
  
  
  class Context_(Spec):
      class run_:
+         def _honors(self, kwarg, value):
-         @patch('invoke.context.run')
+             with patch('invoke.context.run') as run:
-         def honors_warn_state(self, run):
-             Context(run={'warn': True}).run('x')
+                 Context(run={kwarg: value}).run('x')
-             run.assert_called_with('x', warn=True)
+                 run.assert_called_with('x', **{kwarg: value})
  
+         def honors_warn_state(self):
+             self._honors('warn', True)
+ 
+         def honors_hide_state(self):
+             self._honors('hide', 'both')
+ 
Refactor + add test for run(hide)
## Code Before:
from spec import Spec
from mock import patch

from invoke.context import Context


class Context_(Spec):
    class run_:
        @patch('invoke.context.run')
        def honors_warn_state(self, run):
            Context(run={'warn': True}).run('x')
            run.assert_called_with('x', warn=True)

## Instruction:
Refactor + add test for run(hide)
## Code After:
from spec import Spec
from mock import patch

from invoke.context import Context


class Context_(Spec):
    class run_:
        def _honors(self, kwarg, value):
            with patch('invoke.context.run') as run:
                Context(run={kwarg: value}).run('x')
                run.assert_called_with('x', **{kwarg: value})

        def honors_warn_state(self):
            self._honors('warn', True)

        def honors_hide_state(self):
            self._honors('hide', 'both')
