+
     h>  c                   sN   ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	H
t
 ^RIHt ^RIHt ^RIHt ^RIHt ]P"                  '       d   ^RIHt  ! R R	4      t] P*                  R
 R l4       t ! R R]P.                  4      tR R lt ! R R4      t ! R R4      tR# )i    N)TracebackType)
formatting)termui)utils)_find_binary_reader)BaseCommandc                   s   a  ] tR t^t o V 3R lR ltV 3R lR ltV 3R lR ltRV 3R lR lltRV 3R	 lR
 lltRV 3R lR llt	V 3R lR lt
V 3R lR ltV 3R lR ltRtV tR# )EchoingStdinc                sR   < V ^8  d   QhRS[ P                  RS[ P                  RR/# )   inputoutputreturnN)tBinaryIOformat__classdict__   "2/usr/lib/python3.14/site-packages/click/testing.py__annotate__EchoingStdin.__annotate__   s*      ajj !**      c                s,    Wn         W n        R V n        R# )FN_input_output_paused)selfr   r	   s   &&&r   __init__ZEchoingStdin.__init__   s    r   c                s:   < V ^8  d   QhRS[ RS[P                  /# )r   xr
   )strr   Anyr   r   r   r   r      s     ' 'S 'QUU 'r   c                s.    \        V P                  V4      # N)Zgetattrr   r   r      &&r   __getattr__ZEchoingStdin.__getattr__   s    t{{A&&r   c                s&   < V ^8  d   QhRS[ RS[ /# )r   rvr
   )bytesr   r   r   r   r      s       % r   c                s`    V P                   '       g   V P                  P                  V4       V# r   )r   r   write)r   r"   r    r   _echoZEchoingStdin._echo   s"    |||LLr"	r   c                &   < V ^8  d   QhRS[ RS[/# r   nr
   intr#   r   r   r   r   r   #   s     / /c /5 /r   c                V    V P                  V P                  P                  V4      4      # r   )r%   r   readr   r(   r    r   r,   ZEchoingStdin.read#   s     zz$++**1-..r   c                r&   r'   r)   r   r   r   r   r   &   s     0 0s 0E 0r   c                r+   r   )r%   r   read1r-   r    r   r.   ZEchoingStdin.read1&   s     zz$++++A.//r   c                r&   r'   r)   r   r   r   r   r   )   s     3 3# 3u 3r   c                r+   r   )r%   r   readliner-   r    r   r/   ZEchoingStdin.readline)   s     zz$++..q122r   c                D   < V ^8  d   QhRS[ P                  S[,          /# r   r
   )r   ZListr#   r   r   r   r   r   ,   s     @ @166%= @r   c                s|    V P                   P                  4        Uu. uF  qP                  V4      NK  	  up# u upi r   )r   	readlinesr%   r      & r   r2   ZEchoingStdin.readlines,   s/    '+{{'<'<'>?'>!

1'>???s   9c                r0   r1   )r   Iteratorr#   r   r   r   r   r   /   s     8 8!**U+ 8r   c                sB   a  \        V 3R  lS P                   4       4      # )c              3   sF   <"   T F  pSP                  V4      x  K  	  R # 5ir   )r%   )Z.0r   r      & r   Z	<genexpr>Z(EchoingStdin.__iter__.<locals>.<genexpr>0   s     7;aDJJqMM;s   !)Ziterr   r   s   fr   __iter__ZEchoingStdin.__iter__/   s    74;;777r   c                    < V ^8  d   QhRS[ /# r1   r   r   r   r   r   r   2   s     ! !# !r   c                s,    \        V P                  4      # r   )reprr   r6      &r   __repr__ZEchoingStdin.__repr__2   s    DKK  r   r   N)i)__name__
__module____qualname____firstlineno__r   r!   r%   r,   r.   r/   r2   r7   r<   __static_attributes____classdictcell__r      @r   r   r      sa      
' ' / /0 03 3@ @8 8! !r   r   c                s|    V ^8  d   QhR\         P                  \        ,          R\         P                  R,          /# )r   streamr
   N)r   Optionalr   r4   r      "r   r   r   7   s,      

<0 QZZ5E r   c              #   sF   "   V f   R x  R # RV n         R x  RV n         R # 5i)NTF)r   )rE   r;   r   _pause_echorI   6   s     ~s   !c                   sv   a a ] tR t^@t oV3R lV 3R llt]V3R lR l4       t]V3R lR l4       tRtVt	V ;t
# )_NamedTextIOWrapperc          
      s^   < V ^8  d   QhRS[ P                  RS[RS[RS[ P                  RR/# )r   buffernamemodekwargsr
   N)r   r   r   r   r   r   r   r    _NamedTextIOWrapper.__annotate__A   s=      jj(+36BC%%	r   c                sB   < \         SV `  ! V3/ VB  W n        W0n        R # r   )Zsuperr   _name_mode)r   rK   rL   rM   rN   	__class__s   &&&&,r   r   Z_NamedTextIOWrapper.__init__A   s!     	*6*

r   c                r8   r1   r9   r   r   r   r   rO   I         c r   c                    V P                   # r   )rP   r6   r;   r   rL   Z_NamedTextIOWrapper.nameH       zzr   c                r8   r1   r9   r   r   r   r   rO   M   rS   r   c                rT   r   )rQ   r6   r;   r   rM   Z_NamedTextIOWrapper.modeL   rU   r   )rQ   rP   )r=   r>   r?   r@   r   propertyrL   rM   rA   rB   Z__classcell__)rR   r   s   @@r   rJ   rJ   @   s<           r   rJ   c                s    V ^8  d   QhR\         P                  \         P                  \        \        \         P
                  \         P                  ,          3,          ,          R\        R\         P                  /# )r   r   charsetr
   )r   rF   Unionr   r#   IOr   r   rG   rH   r   r   r   Q   sM      ::aggc5!$$quu+567BEZZr   c                 sV   \        V R 4      '       dU   \        \        P                  ! \        P                  \        P
                  ,          V 4      4      pVe   V# \        R4      hV f   Rp M'\        V \        4      '       d   V P                  V4      p \        P                  ! V 4      # )r,   z.Could not find binary reader for input stream.r   )Zhasattrr   r   castrY   r   Z	TypeError
isinstancer   ZencodeioBytesIO)r   rW   r"      && r   make_input_streamr_   Q   s|     uf QUUU!;<>IHII}	E3		W%::er   c                   s   a  ] tR t^et o RtRV 3R lR llt]V 3R lR l4       t]V 3R lR l4       t]V 3R	 lR
 l4       t	V 3R lR lt
RtV tR# )Resultz3Holds the captured result of an invoked CLI script.Nc                s  < V ^8  d   QhRRRS[ RS[P                  S[ ,          RS[P                  RS[RS[P                  S[,          RS[P                  S[P                  S[P                  S[,          S[S[3,          ,          /# )	r   runner	CliRunnerstdout_bytesstderr_bytesreturn_value	exit_code	exceptionexc_info)	r#   r   rF   r   r*   ZBaseExceptionTupleZTyper    r   r   r   r   Result.__annotate__h   s     ! !! ! jj'	!
 ee! ! ::m,! **GGAFF=)=-GH
!r   c                sZ    Wn         W n        W0n        W@n        WPn        W`n        Wpn        R # r   ra   rc   rd   re   rf   rg   rh   )r   ra   rc   rd   re   rf   rg   rh   s   &&&&&&&&r   r   ZResult.__init__h   s,     (( )"" r   c                r8   r1   r9   r   r   r   r   rj      s       r   c                rT   )z(The (standard) output as unicode string.)stdoutr6   r;   r   r	   ZResult.output   s     {{r   c                r8   r1   r9   r   r   r   r   rj      s     
 
 
r   c                s    V P                   P                  V P                  P                  R4      P	                  RR4      # )z&The standard output as unicode string.replace

)rc   decodera   rW   rm   r6   r;   r   rl   ZResult.stdout   s9       ''(;(;YGOOD
 	
r   c                r8   r1   r9   r   r   r   r   rj      s     
 
 
r   c                s    V P                   f   \        R4      hV P                   P                  V P                  P                  R4      P                  RR4      # )z%The standard error as unicode string.zstderr not separately capturedrm   rn   ro   )rd   Z
ValueErrorrp   ra   rW   rm   r6   r;   r   stderrZResult.stderr   sQ     $=>>  ''(;(;YGOOD
 	
r   c                r8   r1   r9   r   r   r   r   rj      s     4 4# 4r   c                s    V P                   '       d   \        V P                   4      MR pR\        V 4      P                   RV R2# )ZokayZ<Z Z>)rg   r:   Ztyper=   )r   Zexc_strr3   r   r<   ZResult.__repr__   s:    *....$t~~&f4:&&'q	33r   )rh   rg   rf   re   ra   rd   rc   r   )r=   r>   r?   r@   __doc__r   rV   r	   rl   rq   r<   rA   rB   rC   rD   r   r`   r`   e   sX     =! !:   
 
 
 
4 4r   r`   c                   s   a  ] tR t^t o RtRV 3R lR lltV 3R lR ltRV 3R lR llt]P                  RV 3R	 lR
 ll4       t
RV 3R lR llt]P                  RV 3R lR ll4       tRtV tR# )rb   a  The CLI runner provides functionality to invoke a Click command line
script for unittesting purposes in a isolated environment.  This only
works in single-threaded systems without any concurrency as it changes the
global interpreter state.

:param charset: the character set for the input and output data.
:param env: a dictionary with environment variables for overriding.
:param echo_stdin: if this is set to `True`, then reading from stdin writes
                   to stdout.  This is useful for showing examples in
                   some circumstances.  Note that regular prompts
                   will automatically echo the input.
:param mix_stderr: if this is set to `False`, then stdout and stderr are
                   preserved as independent streams.  This is useful for
                   Unix-philosophy apps that have predictable stdout and
                   noisy stderr, such that each may be measured
                   independently
Nc          
      s   < V ^8  d   QhRS[ RS[P                  S[P                  S[ S[P                  S[ ,          3,          ,          RS[RS[RR/# )r   rW   env
echo_stdin
mix_stderrr
   N)r   r   rF   Mappingboolr   r   r   r   CliRunner.__annotate__   s\     
% 
%
% ZZ		#qzz#"678
% 	
%
 
% 

%r   c                sL    Wn         T;'       g    / V n        W0n        W@n        R # r   )rW   rs   rt   ru   )r   rW   rs   rt   ru   s   &&&&&r   r   ZCliRunner.__init__   s      47II2$$r   c                s$   < V ^8  d   QhRRRS[ /# )r   clir   r
   r9   r   r   r   r   rx      s     " " "3 "r   c                s.    VP                   ;'       g    R# )zGiven a command object it will return the default program name
for it.  The default is the `name` attribute or ``"root"`` if not
set.
Zroot)rL   )r   ry   r    r   get_default_prog_nameZCliRunner.get_default_prog_name   s    
 xx!!6!r   c                s   < V ^8  d   QhRS[ P                  S[ P                  S[S[ P                  S[,          3,          ,          RS[ P                  S[S[ P                  S[,          3,          /# )r   	overridesr
   )r   rF   rv   r   r   r   r   r   rx      sR      AIIc1::c?.B$CD	
3

3'	(r   c                sb    \        V P                  4      pV'       d   VP                  V4       V# )z8Returns the environment overrides for invoking a script.)Zdictrs   Zupdate)r   r{   r"   r^   r   make_envZCliRunner.make_env   s%     $((^IIi 	r   c                s  < V ^8  d   QhRS[ P                  S[ P                  S[S[S[ P
                  S[ P                  ,          3,          ,          RS[ P                  S[ P                  S[S[ P                  S[,          3,          ,          RS[RS[ P                  S[ P                  S[P                  S[ P                  S[P                  ,          3,          ,          /# )r   r   rs   colorr
   )r   rF   rX   r   r#   rY   r   rv   rw   r4   ri   r\   r]   r   r   r   r   rx      s     L7 L7zz!''#uadd155k"9:;L7 ZZ		#qzz#"678L7 	L7
 
AGGBJJ

2::(>>?	@L7r   c              #  sr  aa"   \        WP                  4      pRp\        P                  p\        P                  p\        P
                  p\        P                  p	^P\        n        V P                  V4      p\        P                  ! 4       p
V P                  '       d0   \        P                  ! \        P                  \        WJ4      4      ;rE\!        W@P                  RRR7      ;\        n        oV P                  '       d   ^Sn        \!        WP                  RRR7      \        n        RpV P$                  '       d   \        P                  \        n        M8\        P                  ! 4       p\!        VV P                  RRRR	7      \        n        \'        V4      RR
 V3R lll4       p\'        V4      RR V3R lll4       p\'        V4      R R l4       pVoRR V3R lllp\(        P*                  p\(        P,                  p\(        P.                  p\0        P2                  pV\(        n        V\(        n        V\(        n        V\0        n        / p VP5                  4        FS  w  pp\6        P8                  P;                  V4      VV&   Vf    \6        P8                  V K@  V\6        P8                  V&   KU  	  W3x  VP5                  4        F1  w  ppVf    \6        P8                  V K  V\6        P8                  V&   K3  	  V\        n        V\        n        V\        n        V\(        n        V\(        n        V\(        n        V\0        n        V	\        n        R#   \<         d     EK
  i ; i  \<         d     K  i ; i  TP5                  4        FC  w  ppTf'    \6        P8                  T K    \<         d     K,  i ; iT\6        P8                  T&   KE  	  T\        n        T\        n        T\        n        T\(        n        T\(        n        T\(        n        T\0        n        T	\        n        i ; i5i)a  A context manager that sets up the isolation for invoking of a
command line tool.  This sets up stdin with the given input data
and `os.environ` with the overrides from the given dictionary.
This also rebinds some internals in Click to be mocked (like the
prompt functionality).

This is automatically done in the :meth:`invoke` method.

:param input: the input stream to put into sys.stdin.
:param env: the environment overrides as dictionary.
:param color: whether the output should contain color codes. The
              application can still override this explicitly.

.. versionchanged:: 8.0
    ``stderr`` is opened with ``errors="backslashreplace"``
    instead of the default ``"strict"``.

.. versionchanged:: 4.0
    Added the ``color`` parameter.
Nz<stdin>Zr)encodingrL   rM   z<stdout>Zwz<stderr>Zbackslashreplace)r~   rL   rM   Zerrorsc                Z    V ^8  d   QhR\         P                  \        ,          R\        /# r   promptr
   r   rF   r   rG   rH   r   r   )CliRunner.isolation.<locals>.__annotate__  s"     	 	!**S/ 	S 	r   c                 s  < \         P                  P                  T ;'       g    R 4       SP                  4       P	                  R4      p\         P                  P                  V R24       \         P                  P                  4        V# ) rn   ro   )sysrl   r$   r/   rstripflush)r   Zval
text_inputr5   r   visible_inputZ*CliRunner.isolation.<locals>.visible_input  sa    JJV\\r*%%'..v6CJJuBZ(JJJr   c                r   r   r   rG   rH   r   r   r     s"     	8 	8C 	8C 	8r   c                 s   < \         P                  P                  T ;'       g    R  R24       \         P                  P                  4        SP	                  4       P                  R4      # )r   ro   rn   )r   rl   r$   r   r/   r   )r   r   s   &r   hidden_inputZ)CliRunner.isolation.<locals>.hidden_input  sL    JJ"~R01JJ&&(//77r   c                s0    V ^8  d   QhR\         R\        /# )r   echor
   )rw   r   rG   rH   r   r   r   $  s     	 	4 	C 	r   c                 s    \         P                  P                  ^4      pV '       d    \         P                  P	                  V4       \         P                  P                  4        V# )i   )r   stdinr,   rl   r$   r   )r   Zcharr3   r   _getcharZ%CliRunner.isolation.<locals>._getchar#  s>    99>>!$D

  &JJKr   c                s    V ^8  d   QhR\         P                  \         P                  \         P                  ,          ,          R\         P                  \        ,          R\        /# )r   rE   r}   r
   )r   rF   rY   r   rw   rG   rH   r   r   r   /  sB     	 	JJqttAEE{+	;<::d;K		r   c                 s(   < Vf   S'       * # V'       * # r    )rE   r}   default_colors   &&r   should_strip_ansiZ.CliRunner.isolation.<locals>.should_strip_ansi/  s     }(((9r   r   )NN)r_   rW   r   r   rl   rq   r   ZFORCED_WIDTHr|   r\   r]   rt   r   rZ   r   r   rJ   Z_CHUNK_SIZEru   rI   r   Zvisible_prompt_funcZhidden_prompt_funcr   r   r   ZitemsosZenvironZget	Exception)r   r   rs   r}   Zbytes_inputZ
echo_inputZ	old_stdinZ
old_stdoutZ
old_stderrZold_forced_widthZbytes_outputZbytes_errorr   r   r   r   Zold_visible_prompt_funcZold_hidden_prompt_funcZold__getchar_funcZold_should_strip_ansiZold_envZkeyZvaluer   r   s   &&&&                   @@r   	isolationZCliRunner.isolation   s]    6 (||<
II	ZZ
ZZ
%22"$
mmC zz|???'(vv

LC( K "5,,YS"
 	
	J ??? &'J"(<<js

 ???CJ**,K,)CJ 
Z	 	 	 
!	 
Z	 	8 	8 
!	8
 
Z	 	 
!	 	 	 #)"<"<!'!:!:"OO % 7 7%2"$0!""3	7!iik
U!zz~~c2=JJsO ',BJJsO *  --%mmo
U=JJsO ',BJJsO . $CJ#CJ!CI)@F&(>F%/FO&;E#&6J#+ %  % 	 &mmo
U=JJsO$  ',BJJsO . $CJ#CJ!CI)@F&(>F%/FO&;E#&6J#s   IP7<N M!N ?P7M1+A3P7M.)N -M..N 1N <P7?N  P7P4N20P42O	=P4 O	A3P44P7c                s  < V ^8  d   QhRRRS[ P                  S[ P                  S[S[ P                  S[,          3,          ,          RS[ P                  S[ P                  S[S[S[ P                  S[ P                  ,          3,          ,          RS[ P                  S[ P                  S[S[ P                  S[,          3,          ,          RS[	RS[	RS[ P                  R	S[
/# )
r   ry   r   argsr   rs   catch_exceptionsr}   extrar
   )r   rF   rX   r   ZSequencer#   rY   r   rv   rw   r`   r   r   r   r   rx   ]  s     c
 c
c
 jjajjo!567c
 zz!''#uadd155k"9:;	c

 ZZ		#qzz#"678c
 c
 c
 c
 
c
r   c           
     s   RpV P                  W4VR7      ;_uu_ 4       p	Rp
Rp^ p\        V\        4      '       d   \        P                  ! V4      p VP                  R4      p VP                  ! RRT;'       g    RRV/VB p
\        P&                  P-                  4        V	^ ,          P/                  4       pV P0                  '       d   RpMV	^,          P/                  4       p RRR4       \3        V XXX
XXVR7      #   \         d    T P                  T4      p Li ; i  \         d   p\        P                  ! 4       p\        P                  ! \        P                  \        P                  \         \        P"                  3,          ,          TP$                  4      pTf   ^ pT^ 8w  d   Tp\        T\         4      '       gJ   \        P&                  P)                  \        T4      4       \        P&                  P)                  R4       ^pTp Rp?ELRp?i\*         d.   pT'       g   h Tp^p\        P                  ! 4       p Rp?ELRp?ii ; i  \        P&                  P-                  4        T	^ ,          P/                  4       pT P0                  '       d   Rpi T	^,          P/                  4       pi ; i  + '       g   i     EL; i)a  Invokes a command in an isolated environment.  The arguments are
forwarded directly to the command line script, the `extra` keyword
arguments are passed to the :meth:`~clickpkg.Command.main` function of
the command.

This returns a :class:`Result` object.

:param cli: the command to invoke
:param args: the arguments to invoke. It may be given as an iterable
             or a string. When given as string it will be interpreted
             as a Unix shell command. More details at
             :func:`shlex.split`.
:param input: the input data for `sys.stdin`.
:param env: the environment overrides.
:param catch_exceptions: Whether to catch any other exceptions than
                         ``SystemExit``.
:param extra: the keyword arguments to pass to :meth:`main`.
:param color: whether the output should contain color codes. The
              application can still override this explicitly.

.. versionchanged:: 8.0
    The result object has the ``return_value`` attribute with
    the value returned from the invoked command.

.. versionchanged:: 4.0
    Added the ``color`` parameter.

.. versionchanged:: 3.0
    Added the ``catch_exceptions`` parameter.

.. versionchanged:: 3.0
    The result object has the ``exc_info`` attribute with the
    traceback if available.
N)r   rs   r}   	prog_namer   ro   rk   r   )r   r[   r   shlexZsplitZpopZKeyErrorrz   ZmainZ
SystemExitr   rh   r   rZ   rF   rX   r*   r   Zcoderl   r$   r   r   Zgetvalueru   r`   )r   ry   r   r   rs   r   r}   r   rh   Z
outstreamsre   rg   rf   r   ZeZe_coderl   rq   s   &&&&&&&,          r   invokeZCliRunner.invoke]  s)   X ^^%^>>*L37II$$${{4(<!IIk2	6"xxVTZZRV9VPUV2 

  "#A//1???!F']335FY ?\ %
 	
I  < 66s;	<
  #<<>

1773:+> ?H>FQ; !I!&#..JJ$$S[1JJ$$T*F"	 *'		<<>* 

  "#A//1???!F']335FY ?>>sz   3J;D $ D"A"J; DJ;DJ;"I-C$HII$I%"IIIIA#J88J;;K	c                s   < V ^8  d   QhRS[ P                  S[ P                  S[R3,          ,          RS[ P                  S[,          /# )r   temp_dirzos.PathLike[str]r
   )r   rF   rX   r   r4   r   r   r   r   rx     s=      

17730B+B#CD	
Cr   c              #  s  "   \         P                  ! 4       p\        P                  ! VR7      p\         P                  ! V4        Vx  \         P                  ! V4       Vf    \
        P                  ! V4       R# R#   \         d     R# i ; i  \         P                  ! T4       Tf*    \
        P                  ! T4       i   \         d     i i ; ii ; i5i)a  A context manager that creates a temporary directory and
changes the current working directory to it. This isolates tests
that affect the contents of the CWD to prevent them from
interfering with each other.

:param temp_dir: Create the temporary directory under this
    directory. If given, the created directory is not removed
    when exiting.

.. versionchanged:: 8.0
    Added the ``temp_dir`` parameter.
)ZdirN)r   ZgetcwdtempfileZmkdtempZchdirshutilZrmtreeZOSError)r   r   ZcwdZdts   &&  r   isolated_filesystemZCliRunner.isolated_filesystem  s       iik(+
		HHHSMMM"%     HHSMMM"%   sf   ACB 
C%A? ;C?B
CBCC-CCCCCCC)rW   rt   rs   ru   )zutf-8NFTr   )NNF)NNNTF)r=   r>   r?   r@   rr   r   rz   r|   
contextlibcontextmanagerr   r   r   rA   rB   rC   rD   r   rb   rb      sw     $
% 
%" "  L7 L7 L7\c
 c
J   r   rb   )r   r\   r   r   r   r   r   Ztypingr   Ztypesr    r   r   r   r   Z_compatr   ZTYPE_CHECKINGZcorer   r   r   rI   ZTextIOWrapperrJ   r_   r`   rb   r   r   r   <module>r      s     	 	   
       (???!! !D  "** "(74 74t@ @r   