Files
ServerSync/lib/invoke/__pycache__/context.cpython-314.pyc

338 lines
24 KiB
Plaintext
Raw Normal View History

2026-02-12 02:28:23 +02:00
+
t<10>i<EFBFBD>c<00><00><><00>^RIt^RIt^RIHt^RIHt^RIHt^RIHtH t H
t
H t H t H t Ht^RIHt^RIHtHt^RIHtHtHt^R IHt^R
IHt]'d^R IHt!R R ]4t!RR]4tR#)<10>N)<01>contextmanager)<01>cycle)<01>PathLike)<07> TYPE_CHECKING<4E>Any<6E> Generator<6F>Iterator<6F>List<73>Optional<61>Union)<01>Mock)<02>Config<69> DataProxy)<03>Failure<72> AuthFailure<72>ResponseNotAccepted)<01>Result)<01>FailingResponder)<01>Runnerc<00>4a<00>]tRt^toRtRV3RlRllt]V3RlRl4t]PV3RlRl4tV3R lR
lt V3R lR lt
V3R lRlt V3RlRlt V3RlRlt ]V3RlRl4t]V3RlRl4t]V3RlRl4tRtVtR#)<1B>Contexta<74>
Context-aware API wrapper & state-passing object.
`.Context` objects are created during command-line parsing (or, if desired,
by hand) and used to share parser and configuration state with executed
tasks (see :ref:`why-context`).
Specifically, the class offers wrappers for core API calls (such as `.run`)
which take into account CLI parser flags, configuration files, and/or
changes made at runtime. It also acts as a proxy for its `~.Context.config`
attribute - see that attribute's documentation for details.
Instances of `.Context` may be shared between tasks when executing
sub-tasks - either the same context the caller was given, or an altered
copy thereof (or, theoretically, a brand new one).
.. versionadded:: 1.0
Nc<00>4<<01>V^8<>dQhRS[S[,RR/#)<04><00>config<69>returnN)r r)<02>format<61> __classdict__s"<22><>5/tmp/pip-target-zhdecbcm/lib/python/invoke/context.py<70> __annotate__<5F>Context.__annotate__.s <00><><00>-<2D>-<2D>x<EFBFBD><06>/<2F>-<2D>4<EFBFBD>-<2D>c <0C><><00>VeTM \4pVPVR7\4pVPVR7\4pVPVR7R#)z<>
:param config:
`.Config` object to use as the base configuration.
Defaults to an anonymous/default `.Config` instance.
N<EFBFBD><01>_config)<01>command_prefixes)<01> command_cwds)r<00>_set<65>list)<04>selfrr%r&s&& r<00>__init__<5F>Context.__init__.sP<00><00> "<22>-<2D><16>6<EFBFBD>8<EFBFBD><06> <0C> <09> <09>&<26> <09>!<21>'+<2B>f<EFBFBD><18> <0C> <09> <09>#3<> <09>4<>#'<27>&<26> <0C> <0C> <09> <09>|<7C> <09>,r!c<00> <<01>V^8<>dQhRS[/#<00>rr<00>r)rrs"<22>rrr Ls<00><><00><1C><1C><06>r!c<08><00>VP#<00>Nr#)r)s&rr<00>Context.configKs<00><00><14>|<7C>|<7C>r!c<00>$<<01>V^8<>dQhRS[RR/#)r<00>valuerNr.)rrs"<22>rrr Rs<00><><00>!<21>!<21>F<EFBFBD>!<21>t<EFBFBD>!r!c<08>*<00>VPVR7R#)r#N)r')r)r3s&&rrr1Qs<00><00> <0A> <09> <09>%<25> <09> r!c<00><<<01>V^8<>dQhRS[RS[RS[S[,/#<00>r<00>command<6E>kwargsr<00><04>strrr r)rrs"<22>rrr Zs'<00><><00>4<>4<>3<EFBFBD>4<>#<23>4<>(<28>6<EFBFBD>2B<32>4r!c <0C>r<00>VPPPV4pVP!W13/VB#)a`
Execute a local shell command, honoring config options.
Specifically, this method instantiates a `.Runner` subclass (according
to the ``runner`` config option; default is `.Local`) and calls its
``.run`` method with ``command`` and ``kwargs``.
See `.Runner.run` for details on ``command`` and the available keyword
arguments.
.. versionadded:: 1.0
)r<00>runners<72>local<61>_run<75>r)r7r8<00>runners&&, r<00>run<75> Context.runZs2<00><00><16><1B><1B>$<24>$<24>*<2A>*<2A>4<EFBFBD>0<><06><13>y<EFBFBD>y<EFBFBD><16>3<>F<EFBFBD>3<>3r!c <00>@<<01>V^8<>dQhRRRS[RS[RS[S[,/#<00>rr@rr7r8rr9)rrs"<22>rrr ms2<00><><00>-<2D>-<2D><1E>-<2D>),<2C>-<2D>8;<3B>-<2D> <11>&<26> <19>-r!c <08>J<00>VPV4pVP!V3/VB#r0)<02>_prefix_commandsrA)r)r@r7r8s&&&,rr><00> Context._runms(<00><00><17>'<27>'<27><07>0<><07><15>z<EFBFBD>z<EFBFBD>'<27>,<2C>V<EFBFBD>,<2C>,r!c<00><<<01>V^8<>dQhRS[RS[RS[S[,/#r6r9)rrs"<22>rrr ss,<00><><00>F5<>F5<>C<EFBFBD>F5<>3<EFBFBD>F5<>8<EFBFBD>F<EFBFBD>3C<33>F5r!c <0C>r<00>VPPPV4pVP!W13/VB#)a
Execute a shell command via ``sudo`` with password auto-response.
**Basics**
This method is identical to `run` but adds a handful of
convenient behaviors around invoking the ``sudo`` program. It doesn't
do anything users could not do themselves by wrapping `run`, but the
use case is too common to make users reinvent these wheels themselves.
.. note::
If you intend to respond to sudo's password prompt by hand, just
use ``run("sudo command")`` instead! The autoresponding features in
this method will just get in your way.
Specifically, `sudo`:
* Places a `.FailingResponder` into the ``watchers`` kwarg (see
:doc:`/concepts/watchers`) which:
* searches for the configured ``sudo`` password prompt;
* responds with the configured sudo password (``sudo.password``
from the :doc:`configuration </concepts/configuration>`);
* can tell when that response causes an authentication failure
(e.g. if the system requires a password and one was not
configured), and raises `.AuthFailure` if so.
* Builds a ``sudo`` command string using the supplied ``command``
argument, prefixed by various flags (see below);
* Executes that command via a call to `run`, returning the result.
**Flags used**
``sudo`` flags used under the hood include:
- ``-S`` to allow auto-responding of password via stdin;
- ``-p <prompt>`` to explicitly state the prompt to use, so we can be
sure our auto-responder knows what to look for;
- ``-u <user>`` if ``user`` is not ``None``, to execute the command as
a user other than ``root``;
- When ``-u`` is present, ``-H`` is also added, to ensure the
subprocess has the requested user's ``$HOME`` set properly.
**Configuring behavior**
There are a couple of ways to change how this method behaves:
- Because it wraps `run`, it honors all `run` config parameters and
keyword arguments, in the same way that `run` does.
- Thus, invocations such as ``c.sudo('command', echo=True)`` are
possible, and if a config layer (such as a config file or env
var) specifies that e.g. ``run.warn = True``, that too will take
effect under `sudo`.
- `sudo` has its own set of keyword arguments (see below) and they are
also all controllable via the configuration system, under the
``sudo.*`` tree.
- Thus you could, for example, pre-set a sudo user in a config
file; such as an ``invoke.json`` containing ``{"sudo": {"user":
"someuser"}}``.
:param str password: Runtime override for ``sudo.password``.
:param str user: Runtime override for ``sudo.user``.
.. versionadded:: 1.0
)rr<r=<00>_sudor?s&&, r<00>sudo<64> Context.sudoss3<00><00>J<16><1B><1B>$<24>$<24>*<2A>*<2A>4<EFBFBD>0<><06><13>z<EFBFBD>z<EFBFBD>&<26>4<>V<EFBFBD>4<>4r!c <00>@<<01>V^8<>dQhRRRS[RS[RS[S[,/#rDr9)rrs"<22>rrr <00>s2<00><><00>;<16>;<16><1E>;<16>),<2C>;<16>8;<3B>;<16> <11>&<26> <19>;r!c <08><><00>VPPPpVPRVPPP4pVPRVPPP
4pVP R/4pRpVeRPV4pRp V'd/RPRPVP444p VPV4pRPWIW<49>4p
\\P!V4R PV4R
R 7p VPR \VPPP 44p V P#V 4VP!V
3R V /VB# \$d@p \'T P(\*4'd\-T P.TR 7pThhRp ? ii;i)<0E>password<72>user<65>env<6E>Nz -H -u {} z--preserve-env='{}' <20>,zsudo -S -p '{}' {}{}{}z{}
zSorry, try again.
)<03>pattern<72>response<73>sentinel<65>watchers)<02>result<6C>prompt)rrKrY<00>poprOrP<00>getr<00>join<69>keysrFr<00>re<72>escaper(rArW<00>appendr<00>
isinstance<EFBFBD>reasonrrrX)r)r@r7r8rYrOrPrQ<00>
user_flags<EFBFBD> env_flags<67>cmd_str<74>watcherrW<00>failure<72>errors&&&, rrJ<00> Context._sudo<64>s<><00><00><16><1B><1B>!<21>!<21>(<28>(<28><06><19>:<3A>:<3A>j<EFBFBD>$<24>+<2B>+<2B>*:<3A>*:<3A>*C<>*C<>D<><08><15>z<EFBFBD>z<EFBFBD>&<26>$<24>+<2B>+<2B>"2<>"2<>"7<>"7<>8<><04><14>j<EFBFBD>j<EFBFBD><15><02>#<23><03><18>
<EFBFBD> <0F> <1B>$<24>+<2B>+<2B>D<EFBFBD>1<>J<EFBFBD><16> <09> <0E>.<2E>5<>5<>c<EFBFBD>h<EFBFBD>h<EFBFBD>s<EFBFBD>x<EFBFBD>x<EFBFBD>z<EFBFBD>6J<36>K<>I<EFBFBD><16>'<27>'<27><07>0<><07>*<2A>1<>1<> <12>z<EFBFBD>
<EFBFBD><07>#<23><16>I<EFBFBD>I<EFBFBD>f<EFBFBD>%<25><1B>]<5D>]<5D>8<EFBFBD>,<2C>*<2A>
<EFBFBD><07><1A>:<3A>:<3A>j<EFBFBD>$<24>t<EFBFBD>{<7B>{<7B><EFBFBD><EFBFBD>/G<>/G<>*H<>I<><08><10><0F><0F><07> <20> <16><19>:<3A>:<3A>g<EFBFBD>C<><08>C<>F<EFBFBD>C<> C<><43><16> <16><1A>'<27>.<2E>.<2E>*=<3D>><3E>><3E>#<23>7<EFBFBD>><3E>><3E>&<26>I<><05><1B> <0B><16><> <16>s<00>F<00> G <03>!:G<03>G c<00>&<<01>V^8<>dQhRS[RS[/#)rr7r<00>r:)rrs"<22>rrr <00>s<00><><00> 1<> 1<><03> 1<><03> 1r!c <0C><><00>\VP4pVPpV'd"VP^RP V44RP W!.,4#)z<>
Prefixes ``command`` with all prefixes found in ``command_prefixes``.
``command_prefixes`` is a list of strings which is modified by the
`prefix` context manager.
zcd {}z && )r(r%<00>cwd<77>insertrr\)r)r7<00>prefixes<65>current_directorys&& rrF<00>Context._prefix_commands<64>sM<00><00><18><04>-<2D>-<2D>.<2E><08> <20>H<EFBFBD>H<EFBFBD><19> <1C> <14>O<EFBFBD>O<EFBFBD>A<EFBFBD>w<EFBFBD>~<7E>~<7E>.?<3F>@<40> A<><15>{<7B>{<7B>8<EFBFBD>i<EFBFBD>/<2F>0<>0r!c<00>4<<01>V^8<>dQhRS[RS[R,/#)rr7r<00>NNN)r:r)rrs"<22>rrr s!<00><><00>5(<28>5(<28>c<EFBFBD>5(<28>i<EFBFBD>0@<40>&A<>5(r!c# <0C><>"<00>VPPV4Rx<00>VPP4R# TPP4i;i5i)a<>
Prefix all nested `run`/`sudo` commands with given command plus ``&&``.
Most of the time, you'll want to be using this alongside a shell script
which alters shell state, such as ones which export or alter shell
environment variables.
For example, one of the most common uses of this tool is with the
``workon`` command from `virtualenvwrapper
<https://virtualenvwrapper.readthedocs.io/en/latest/>`_::
with c.prefix('workon myvenv'):
c.run('./manage.py migrate')
In the above snippet, the actual shell command run would be this::
$ workon myvenv && ./manage.py migrate
This context manager is compatible with `cd`, so if your virtualenv
doesn't ``cd`` in its ``postactivate`` script, you could do the
following::
with c.cd('/path/to/app'):
with c.prefix('workon myvenv'):
c.run('./manage.py migrate')
c.run('./manage.py loaddata fixture')
Which would result in executions like so::
$ cd /path/to/app && workon myvenv && ./manage.py migrate
$ cd /path/to/app && workon myvenv && ./manage.py loaddata fixture
Finally, as alluded to above, `prefix` may be nested if desired, e.g.::
with c.prefix('workon myenv'):
c.run('ls')
with c.prefix('source /some/script'):
c.run('touch a_file')
The result::
$ workon myenv && ls
$ workon myenv && source /some/script && touch a_file
Contrived, but hopefully illustrative.
.. versionadded:: 1.0
N)r%r`rZ)r)r7s&&r<00>prefix<69>Context.prefix
sH<00><00><00>d <0A><1D><1D>$<24>$<24>W<EFBFBD>-<2D> (<28> <11> <10> !<21> !<21> %<25> %<25> '<27><>D<EFBFBD> !<21> !<21> %<25> %<25> '<27>s<00>A<01>?<00>A<01>A<03>Ac<00> <<01>V^8<>dQhRS[/#r-rk)rrs"<22>rrr Cs<00><><00>)<29>)<29>S<EFBFBD>)r!c <0C><><00>VP'gR#\\\VP444F5wrVP R4'gVP R4'gK5M VPXRUu.uFq"P RR4NK pp\ \PP!V!4#uupi)z[
Return the current working directory, accounting for uses of `cd`.
.. versionadded:: 1.0
rR<00>~<7E>/N<> z\ )
r&<00>reversedr(<00> enumerate<74>
startswith<EFBFBD>replacer:<00>os<6F>pathr\)r)<00>ir<69><00>pathss& rrm<00> Context.cwdBs<><00><00><14> <20> <20> <20><16> <20><04>Y<EFBFBD>t<EFBFBD>/@<40>/@<40>%A<> B<>C<>G<EFBFBD>A<EFBFBD><13><EFBFBD><EFBFBD>s<EFBFBD>#<23>#<23>t<EFBFBD><EFBFBD><EFBFBD>s<EFBFBD>';<3B>';<3B><15>D<01> 7;<3B>6G<36>6G<36><01><02>6K<36>L<>6K<36>d<EFBFBD><1C><1C>c<EFBFBD>5<EFBFBD>)<29>6K<36><05>L<><12>2<EFBFBD>7<EFBFBD>7<EFBFBD><<3C><<3C><15>'<27>(<28>(<28><>Ms<00>C c<00>J<<01>V^8<>dQhRS[S[S[3,RS[R,/#)rr<>rrs)r rr:r)rrs"<22>rrr Zs*<00><><00>3$<24>3$<24>u<EFBFBD>X<EFBFBD>s<EFBFBD>]<5D>+<2B>3$<24> <09>:J<>0K<30>3$r!c# <0C><>"<00>\V4pVPPV4Rx<00>VPP4R# TPP4i;i5i)ai
Context manager that keeps directory state when executing commands.
Any calls to `run`, `sudo`, within the wrapped block will implicitly
have a string similar to ``"cd <path> && "`` prefixed in order to give
the sense that there is actually statefulness involved.
Because use of `cd` affects all such invocations, any code making use
of the `cwd` property will also be affected by use of `cd`.
Like the actual 'cd' shell builtin, `cd` may be called with relative
paths (keep in mind that your default starting directory is your user's
``$HOME``) and may be nested as well.
Below is a "normal" attempt at using the shell 'cd', which doesn't work
since all commands are executed in individual subprocesses -- state is
**not** kept between invocations of `run` or `sudo`::
c.run('cd /var/www')
c.run('ls')
The above snippet will list the contents of the user's ``$HOME``
instead of ``/var/www``. With `cd`, however, it will work as expected::
with c.cd('/var/www'):
c.run('ls') # Turns into "cd /var/www && ls"
Finally, a demonstration (see inline comments) of nesting::
with c.cd('/var/www'):
c.run('ls') # cd /var/www && ls
with c.cd('website1'):
c.run('ls') # cd /var/www/website1 && ls
.. note::
Space characters will be escaped automatically to make dealing with
such directory names easier.
.. versionadded:: 1.0
.. versionchanged:: 1.5
Explicitly cast the ``path`` argument (the only argument) to a
string; this allows any object defining ``__str__`` to be handed in
(such as the various ``Path`` objects out there), and not just
string literals.
N)r:r&r`rZ)r)r<>s&&r<00>cd<63>
Context.cdYsQ<00><00><00>^<13>4<EFBFBD>y<EFBFBD><04> <0C><19><19> <20> <20><14>&<26> $<24> <11> <10> <1D> <1D> !<21> !<21> #<23><>D<EFBFBD> <1D> <1D> !<21> !<21> #<23>s<00>'A)<01>A
<00>A)<01>
A&<03>&A)<01>r0)<14>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__firstlineno__<5F>__doc__r*<00>propertyr<00>setterrAr>rKrJrFrrurmr<><00>__static_attributes__<5F>__classdictcell__)rs@rrrs<><00><><00><00><08>&-<2D>-<2D>:<0E><1C><0E><1C>
 <0C>]<5D>]<5D>!<21><13>!<21>4<>4<>&-<2D>-<2D> F5<>F5<>R;<16>;<16>@ 1<> 1<><14>5(<28><14>5(<28>n<0E>)<29><0E>)<29>,<14>3$<24><14>3$r!rc<00><>aa<01>]tRtRtoRtRV3RlV3RllltV3RlRltV3RlRltV3R lR
ltV3R lR lt V3R lRlt
Rt Vt V;t #)<11> MockContexti<74>a<>
A `.Context` whose methods' return values can be predetermined.
Primarily useful for testing Invoke-using codebases.
.. note::
This class wraps its ``run``, etc methods in `unittest.mock.Mock`
objects. This allows you to easily assert that the methods (still
returning the values you prepare them with) were actually called.
.. note::
Methods not given `Results <.Result>` to yield will raise
``NotImplementedError`` if called (since the alternative is to call the
real underlying method - typically undesirable when mocking.)
.. versionadded:: 1.0
.. versionchanged:: 1.5
Added ``Mock`` wrapping of ``run`` and ``sudo``.
c<00>:<<01>V^8<>dQhRS[S[,RS[RR/#)rrr8rN)r rr)rrs"<22>rr<00>MockContext.__annotate__<5F>s1<00><><00>NA<01>NA<01>x<EFBFBD><06>/<2F>NA<01>#<23>NA<01>$<24>NAr!c
<0C><><<01>\S V`V4VPRVPRR44VP 4F<>wr4\
\ \3p\V\4'd.VP 4FwrgVPV4WF&K MZ\WE4'g\VR4'dVPV4pM%Rp\VP\V444hVPRPV4V4VPV\\!W4R74K<> R#) a<>
Create a ``Context``-like object whose methods yield `.Result` objects.
:param config:
A Configuration object to use. Identical in behavior to `.Context`.
:param run:
A data structure indicating what `.Result` objects to return from
calls to the instantiated object's `~.Context.run` method (instead
of actually executing the requested shell command).
Specifically, this kwarg accepts:
- A single `.Result` object.
- A boolean; if True, yields a `.Result` whose ``exited`` is ``0``,
and if False, ``1``.
- An iterable of the above values, which will be returned on each
subsequent call to ``.run`` (the first item on the first call,
the second on the second call, etc).
- A dict mapping command strings or compiled regexen to the above
values (including an iterable), allowing specific
call-and-response semantics instead of assuming a call order.
:param sudo:
Identical to ``run``, but whose values are yielded from calls to
`~.Context.sudo`.
:param bool repeat:
A flag determining whether results yielded by this class' methods
repeat or are consumed.
For example, when a single result is indicated, it will normally
only be returned once, causing ``NotImplementedError`` afterwards.
But when ``repeat=True`` is given, that result is returned on
every call, forever.
Similarly, iterable results are normally exhausted once, but when
this setting is enabled, they are wrapped in `itertools.cycle`.
Default: ``True``.
:raises:
``TypeError``, if the values given to ``run`` or other kwargs
aren't of the expected types.
.. versionchanged:: 1.5
Added support for boolean and string result values.
.. versionchanged:: 1.5
Added support for regex dict keys.
.. versionchanged:: 1.5
Added the ``repeat`` keyword argument.
.. versionchanged:: 2.0
Changed ``repeat`` default value from ``False`` to ``True``.
<EFBFBD>__repeat<61>repeatT<74>__iter__z)Not sure how to yield results from a {!r}<7D>__{})<01>wrapsN)<11>superr*r'rZ<00>itemsr<00>boolr:ra<00>dict<63>
_normalize<EFBFBD>hasattr<74> TypeErrorr<00>typer <00>getattr)
r)rr8<00>method<6F>results<74>
singletons<EFBFBD>keyr3<00>err<72> __class__s
&&, <20>rr*<00>MockContext.__init__<5F>s<><00><><00>p <0E><07><18><16> <20> <0C> <09> <09>*<2A>f<EFBFBD>j<EFBFBD>j<EFBFBD><18>4<EFBFBD>8<>9<>%<25>|<7C>|<7C>~<7E>O<EFBFBD>F<EFBFBD>!<21>$<24><03>,<2C>J<EFBFBD><19>'<27>4<EFBFBD>(<28>(<28>")<29>-<2D>-<2D>/<2F>J<EFBFBD>C<EFBFBD>#'<27>?<3F>?<3F>5<EFBFBD>#9<>G<EFBFBD>L<EFBFBD>#2<><1B>G<EFBFBD>0<>0<>G<EFBFBD><17><1A>5<0E>5<0E><1F>/<2F>/<2F>'<27>2<><07>B<01><03><1F><03>
<EFBFBD>
<EFBFBD>4<EFBFBD><07>=<3D> 9<>:<3A>:<3A> <10>I<EFBFBD>I<EFBFBD>f<EFBFBD>m<EFBFBD>m<EFBFBD>F<EFBFBD>+<2B>W<EFBFBD> 5<> <10>I<EFBFBD>I<EFBFBD>f<EFBFBD>d<EFBFBD><17><14>)><3E>?<3F> @<40>% .r!c<00>6<<01>V^8<>dQhRS[RS[S[,/#)rr3r)rr )rrs"<22>rrr<><00>s#<00><><00> N<01> N<01><03> N<01><08><13> <0A> Nr!c<08>|<00>\VR4'd\V\4'dV.p.pVFbp\V\4'd\ V'd^M^R7pM!\V\4'd \ V4pVP V4Kd \ VR4'd \V4#\V4#)r<>)<01>exitedr<64>) r<>rar:r<>rr`r<>r<00>iter)r)r3r<><00>objs&& rr<><00>MockContext._normalize<7A>s<><00><00><16>u<EFBFBD>j<EFBFBD>)<29>)<29>Z<EFBFBD><05>s<EFBFBD>-C<>-C<><1A>G<EFBFBD>E<EFBFBD><14><07><18>C<EFBFBD><19>#<23>t<EFBFBD>$<24>$<24><1C><13>A<EFBFBD>!<21>4<><03><1B>C<EFBFBD><13>%<25>%<25><1C>S<EFBFBD>k<EFBFBD><03> <13>N<EFBFBD>N<EFBFBD>3<EFBFBD> <1F> <19>")<29><14>z<EFBFBD>!:<3A>!:<3A>u<EFBFBD>W<EFBFBD>~<7E>M<><04>W<EFBFBD> <0A>Mr!c<00>,<<01>V^8<>dQhRS[RS[RS[/#)r<00>attnamer7r<00>r:r)rrs"<22>rrr<> s"<00><><00>/<2F>/<2F>S<EFBFBD>/<2F>3<EFBFBD>/<2F>6<EFBFBD>/r!c<08><><00>\W4p\V\4'd
W2,p\V4pVP'gW&nV# \dRTP 4F6wrE\ TR4'gKTP T4'gK2TpKx \hi;i \\\\3d \T4hi;i)<01>match) r<>rar<><00>KeyErrorr<72>r<>r<><00>nextr7<00>AttributeError<6F>
IndexError<EFBFBD> StopIteration<6F>NotImplementedError)r)r<>r7r<>r<>r3rXs&&& r<00> _yield_result<6C>MockContext._yield_result s<><00><00> /<2F><19>$<24>(<28>C<EFBFBD><19>#<23>t<EFBFBD>$<24>$<24> '<27><1D>,<2C>C<EFBFBD>"<22>#<23>Y<EFBFBD>F<EFBFBD><1A>><3E>><3E>><3E>!(<28><0E><19>M<EFBFBD><4D>% <20> '<27>'*<2A>i<EFBFBD>i<EFBFBD>k<EFBFBD>
<EFBFBD><03>"<22>3<EFBFBD><07>0<>0<>S<EFBFBD>Y<EFBFBD>Y<EFBFBD>w<EFBFBD>5G<35>5G<35>"'<27>C<EFBFBD>!<21>'2<> '<27><0E> '<27><>&<1F>
<EFBFBD>H<EFBFBD>m<EFBFBD>D<> /<2F>%<25>g<EFBFBD>.<2E> .<2E> /<2F>s9<00>!B0<00>A<00>$B0<00>/B-<03>B-<03>B-<03>!B0<00>$ B-<03>-B0<00>0'Cc<00>2<<01>V^8<>dQhRS[RS[RS[RS[/#<00>rr7<00>argsr8r<00>r:rr)rrs"<22>rrr<>'s)<00><><00>4<>4<>3<EFBFBD>4<>s<EFBFBD>4<>c<EFBFBD>4<>f<EFBFBD>4r!c<08>&<00>VPRV4#)<01>__run<75>r<><00>r)r7r<>r8s&&*,rrA<00>MockContext.run's<00><00>
<14>!<21>!<21>'<27>7<EFBFBD>3<>3r!c<00>2<<01>V^8<>dQhRS[RS[RS[RS[/#r<>r<>)rrs"<22>rrr<>.s)<00><><00>5<>5<>C<EFBFBD>5<><03>5<>s<EFBFBD>5<>v<EFBFBD>5r!c<08>&<00>VPRV4#)<01>__sudor<6F>r<>s&&*,rrK<00>MockContext.sudo.s<00><00>
<14>!<21>!<21>(<28>G<EFBFBD>4<>4r!c<00>0<<01>V^8<>dQhRS[RS[RS[RR/#)rr<>r7rXrNr<4E>)rrs"<22>rrr<>5s-<00><><00>%1<>%1<><1A>%1<>%(<28>%1<>28<32>%1<> <0A>%1r!c <0C><><00>RPV4p\R4p\W4p\ T\
4'gThTP T4YR&R# \dThi;i)a}
Modify the stored mock results for given ``attname`` (e.g. ``run``).
This is similar to how one instantiates `MockContext` with a ``run`` or
``sudo`` dict kwarg. For example, this::
mc = MockContext(run={'mycommand': Result("mystdout")})
assert mc.run('mycommand').stdout == "mystdout"
is functionally equivalent to this::
mc = MockContext()
mc.set_result_for('run', 'mycommand', Result("mystdout"))
assert mc.run('mycommand').stdout == "mystdout"
`set_result_for` is mostly useful for modifying an already-instantiated
`MockContext`, such as one created by test setup or helper methods.
.. versionadded:: 1.0
r<EFBFBD>z>Can't update results for non-dict or nonexistent mock results!N)rr<>r<>r<>rar<>r<>)r)r<>r7rX<00>heckr3s&&&& r<00>set_result_for<6F>MockContext.set_result_for5sh<00><00>.<19>-<2D>-<2D><07>(<28><07><18> L<>
<EFBFBD><04>  <17><1B>D<EFBFBD>*<2A>E<EFBFBD><1A>%<25><14>&<26>&<26><16>J<EFBFBD><1D><1F><1F><16>0<><05><0E><> <1E> <17><16>J<EFBFBD> <17>s <00> A<00>A$r<>r0)r<>r<>r<>r<>r<>r*r<>r<>rArKr<>r<>r<><00> __classcell__)r<>rs@@rr<>r<><00>sR<00><><00><00><08>(NA<01>NA<01>` N<01> N<01>(/<2F>/<2F><4<>4<>5<>5<>%1<>%1<>%1r!r<>) r<>r^<00>
contextlibr<00> itertoolsrr<00>typingrrrr r
r r <00> unittest.mockr rrr<00>
exceptionsrrrr<rrWr<00>invoke.runnersrrr<>r<>r!r<00><module>r<>sZ<00><01> <09> <09>%<25><1B><17><02><02><02><1F>%<25>A<>A<><1B>&<26><10>%<25>s$<24>i<EFBFBD>s$<24>l J1<>'<27>J1r!