Files
intellecton/venv/lib/python3.12/site-packages/click/__pycache__/testing.cpython-312.pyc
T

363 lines
34 KiB
Plaintext
Raw Normal View History

Ë
judãóäddlmZddlmZddlZddlZddlZddlZddl Z ddl
Z
ddl Z ddl Z
ddlmZddlmZddlmZddlmZddlmZdd lmZe
j,r dd
lmZdd lmZe
j6d ZGd
d«Zej<dd«ZGdd«Z GddejB«Z"Gdd«Z#GddejH«Z% ddZ&Gdd«Z'Gdd«Z(y)é)Ú annotationsN)Ú
TracebackTypeé)Ú_compat)Ú
formatting)Útermui)Úutils)Ú_find_binary_reader)ÚReadableBuffer)ÚCommand)ÚsysÚfdcóZeZdZd dZd dZd
dZdddZdddZdddZddZ ddZ
dd „Z y
)Ú EchoingStdincó.||_||_d|_y)NF)Ú_inputÚ_outputÚ_paused)ÚselfÚinputÚoutputs úP/home/antigravity/intellecton/venv/lib/python3.12/site-packages/click/testing.pyÚ__init__zEchoingStdin.__init__s؈Œ ؈Œ ؈ ócó.t|j|«S©N)Úgetattrr©rÚxs rÚ __getattr__zEchoingStdin.__getattr__"sÜt—{{ &rcóT|js|jj|«|Sr)rrÚwrite)rÚrvs rÚ_echozEchoingStdin._echo%s Ø|Š|Ø L‰L× Ñ ˜ ˆ rcóV|j|jj|««Sr)r$rÚread©rÚns rr&zEchoingStdin.read+s Øz‰z˜$Ÿ+™+×*¨1Ó.rcóV|j|jj|««Sr)r$rÚread1r's rr*zEchoingStdin.read1.s Øz‰z˜$Ÿ+™+×+¨AÓ/rcóV|j|jj|««Sr)r$rÚreadliner's rr,zEchoingStdin.readline1s Øz‰z˜$Ÿ+™+×.¨qÓ2rcóz|jj«Dcgc]}|j|«Œc}Scc}wr)rÚ readlinesr$rs rr.zEchoingStdin.readlines4s+Ø'+§{¡{×'<Ñ'<Ó'>Ö? !
˜1•
Ò?ùÒ?s8có@tˆfdjD««S)Nc3ó@K|]}j|«Œy­wr)r$)Ú.0rrs €rú <genexpr>z(EchoingStdin.__iter__.<locals>.<genexpr>8søèø€Ò7 aD—J‘J˜q—MÑ7ùsƒ)Úiterr©rs`rÚ__iter__zEchoingStdin.__iter__7sø€ÜÓ7¨4¯;©;Ô7rcó,t|j«Sr)Úreprrr4s rÚ__repr__zEchoingStdin.__repr__:sÜD—K Ð rN)rú
t.BinaryIOrr9ÚreturnÚNone)rÚstrr:út.Any)r#Úbytesr:r>)éÿÿÿÿ)r(Úintr:r>)r:z list[bytes])r:zcabc.Iterator[bytes]©r:r<) Ú__name__Ú
__module__Ú __qualname__rr r$r&r*r,r.r5r8©rrrrs0óó
ô @ó!rrc#ó>K|dyd|_dd|_y­w)NTF)r)Ústreams rÚ _pause_echorH>sèø€à
€~Ü
àˆŒÛ
؈ùscó(eZdZdZddZddZddZy) Ú
_FDCaptureaVRedirect a file descriptor to a temporary file for capture.
Saves the current target of *targetfd* via :func:`os.dup`, then
redirects it to a temporary file via :func:`os.dup2`. On
:meth:`stop`, restores the original ``fd`` and returns the captured
bytes. Inspired by Pytest's ``FDCapture``.
.. versionadded:: 8.4.0
có.||_d|_d|_y©Nr?)Ú _targetfdÚsaved_fdÚ_tmpfile)rÚtargetfds rrz_FDCapture.__init__SsØ!ˆŒØˆŒ
Ø+/ˆ
rcóòtj|j«|_t j
d¬«|_tj|j j«|j«y)Nr)Ú buffering) ÚosÚduprMrNÚtempfileÚ
TemporaryFilerOÚdup2Úfilenor4s rÚstartz_FDCapture.startXsGÜŸ˜tŸ~™~ÓŒ
Ü ×.¸Ô;ˆŒ
Ü

ׯ©Õ7rcóx|jJd«tj|j|j«tj
|j«d|_|jj
d«|jj«}|jj «d|_|S)Nz!_FDCapture.start() was not calledr?r)rOrSrWrNrMÚcloseÚseekr&)rÚdatas rÚstopz_FDCapture.stop]s…Ø}‰}ÐMÐ*MÓ

˜tŸ~™~Ô
ÔØˆŒ
Ø
×ј1ÔØ}‰}ר
×ÑÔØˆŒ
؈ rN)rPr@r:r;©r:r;)r:r>)rBrCrDÚ__doc__rrYr^rErrrJrJHsñó

rrJcó<eZdZdZdˆfd Zdˆfd Zdˆfd ZˆxZS)Ú BytesIOCopyzdPatch ``io.BytesIO`` to let the written stream be copied to another.
.. versionadded:: 8.2
có0t|«||_yr)ÚsuperrÚcopy_to)rreÚ __class__s €rrzBytesIOCopy.__init__osø€Ü
ÑÔØˆ rcóVt|«|jj«yr)rdÚflushre©rrfs €rrhzBytesIOCopy.flushssø€Ü

ŒØ ×ÑÕrcóX|jj|«t||«Sr)rer"rd)rÚbrfs €rr"zBytesIOCopy.writews$ø€Ø ×ј1Ô܉w‰}˜QÓÐr)rez
io.BytesIOr:r;r_)rkr r:r@)rBrCrDr`rrhr"Ú
__classcell__©rfs@rrbrbisø„ñõ
õ÷ ñ rrbcóeZdZdZddZy)Ú StreamMixerzMixes `<stdout>` and `<stderr>` streams.
The result is available in the ``output`` attribute.
.. versionadded:: 8.2
có¢tj«|_t|j¬«|_t|j¬«|_y)N)re)ÚioÚBytesIOrrbÚstdoutÚstderrr4s rrzStreamMixer.__init__„s/Ü"$§*¡*£,ˆŒ Ü"-°d·k±kÔ"BˆŒ Ü"-°d·k±kÔ"Bˆ rNr_)rBrCrDr`rrErrroro|s
ñôCrrocópeZdZdZ dˆfd ZddZd ˆfd Zed
d«Zed
d«Z ˆxZ
S) Ú_NamedTextIOWrapperaA :class:`~io.TextIOWrapper` with custom ``name`` and ``mode``
that does not close its underlying buffer.
When ``CliRunner`` runs in ``fd`` mode, ``_original_fd`` is patched to
point at the saved (pre-redirection) ``fd``, so C-level consumers that call
:meth:`fileno` (like ``faulthandler`` or ``subprocess``) keep working. In
the default ``sys`` mode ``_original_fd`` stays at ``-1`` and
:meth:`fileno` raises :exc:`io.UnsupportedOperation`, matching the
pre-``8.3.3`` behavior.
c óPt||fi|¤Ž||_||_d|_yrL)rdrÚ_nameÚ_modeÚ _original_fd)rÚbufferÚnameÚmodeÚkwargsrfs €rrz_NamedTextIOWrapper.__init__s-ø€ô јÑ* 6ÒˆŒ
؈Œ
Ø!#ˆÕrcóy)zÃThe buffer this object contains belongs to some other object,
so prevent the default ``__del__`` implementation from closing
that buffer.
.. versionadded:: 8.3.2
NrEr4s rr[z_NamedTextIOWrapper.close¢srcóV|jdk\r |jSt| «S)zÿReturn the file descriptor of the saved original stream when
``CliRunner`` runs in ``fd`` mode. Otherwise delegate to
:class:`~io.TextIOWrapper`, which raises
:exc:`io.UnsupportedOperation` for a ``BytesIO``-backed buffer.
r)rzrdrXris €rrXz_NamedTextIOWrapper.filenoªs,ø€ð × Ñ  Ò × ‰w‰~ÓÐrcó|jSr)rxr4s rr|z_NamedTextIOWrapper.name´ó àz‰zÐrcó|jSr)ryr4s rr}z_NamedTextIOWrapper.mode¸rr)
r{r9r|r<r}r<r~r=r:r;r_)r:r@rA) rBrCrDr`rr[rXÚpropertyr|r}rlrms@rrvrvŠsoø„ñ ð
ð
ð
ð

ð

õ
 õ ðòóððòóôrrvcóìt|d«r.ttjd|««}||St d«|d}n!t |t «r|j|«}tj|«S)Nr&z t.IO[t.Any]z.Could not find binary reader for input stream.r)
Úhasattrr
ÚcastÚ TypeErrorÚ
isinstancer<Úencoderqrr)rÚcharsetr#s rÚmake_input_streamr½sjôˆuÜ
¤§¡¨
°uÓ!=Ó
>ˆà
ˆ>؈IäÐ €}ØÜ Eœ3Ô Ø ˜WÓä
:‰: ÐrcóxeZdZdZ d d dZed
d«Zed
d«Zed
d«Zd
dZ y) ÚResultaCHolds the captured result of an invoked CLI script.
:param runner: The runner that created the result
:param stdout_bytes: The standard output as bytes.
:param stderr_bytes: The standard error as bytes.
:param output_bytes: A mix of ``stdout_bytes`` and ``stderr_bytes``, as the
user would see it in its terminal.
:param return_value: The value returned from the invoked command.
:param exit_code: The exit code as integer.
:param exception: The exception that happened if one did.
:param exc_info: Exception information (exception type, exception instance,
traceback type).
.. versionchanged:: 8.2
``stderr_bytes`` no longer optional, ``output_bytes`` introduced and
``mix_stderr`` has been removed.
.. versionadded:: 8.0
Added ``return_value``.
Nc ót||_||_||_||_||_||_||_||_yr©ÚrunnerÚ stdout_bytesÚ stderr_bytesÚ output_bytesÚ return_valueÚ exit_codeÚ exceptionÚexc_info) rrr“r”r•r–r—r˜r™s rrzResult.__init__çs@ðˆŒ ØÔØÔØÔØÔØŒØ"ˆŒØ ˆ
rcó‚|jj|jjd«j dd«S)aThe terminal output as unicode string, as the user would see it.
.. versionchanged:: 8.2
No longer a proxy for ``self.stdout``. Now has its own independent stream
that is mixing `<stdout>` and `<stderr>`, in the order they were written.
Úreplaceú
ú
)r•Údecoderrr4s rrz
Result.outputüs9ð× Ñ ×¯ © ×(;Ñ(;¸G× 
ð
rcó‚|jj|jjd«j dd«S)z&The standard output as unicode string.rr)r“rrr4s rrsz
Result.stdouts9ð× Ñ ×¯ © ×(;Ñ(;¸G× 
ð
rcó‚|jj|jjd«j dd«S)zŸThe standard error as unicode string.
.. versionchanged:: 8.2
No longer raise an exception, always returns the `<stderr>` string.
rr)r”rrr4s rrtz
Result.stderrs9ð× Ñ ×¯ © ×(;Ñ(;¸G× 
ð
rcó€|jrt|j«nd}dt|«jd|dS)okayú ú>)r˜r7ÚtyperB)rÚexc_strs rr8zResult.__repr__s8Ø*.¯.ª.”$t—~&¸fˆØ”4˜“:×' ¨ °Ð3rr)rÚ CliRunnerr“r>r”r>r•r>rr=r—r@r˜zBaseException | Noner™z?tuple[type[BaseException], BaseException, TracebackType] | NonerA)
rBrCrDr`rr„rrsrtr8rErrrrÑs ñð>ðððð 
ð  ð
ðó!ð*ò 
óð 
ðò
óð
ð ò
óð
ô4rrcóòeZdZdZ d d
dZd dZ d d
dZej d dd«Z d ddZ
ej d dd«Z y)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 catch_exceptions: Whether to catch any exceptions other than
``SystemExit`` when running :meth:`~CliRunner.invoke`.
:param capture: Selects the output capture strategy. ``sys`` (default)
captures Python-level writes only and leaves
:meth:`sys.stdout.fileno` raising :exc:`io.UnsupportedOperation`, so
user code that calls :func:`os.dup2` on ``sys.stdout.fileno()`` cannot
clobber the host runner's stdout. ``fd`` redirects file descriptors
``1`` and ``2`` via :func:`os.dup2` to a temporary file, also catching
output from stale stream references, C extensions, and subprocesses.
``fd`` is not supported on Windows.
.. versionchanged:: 8.4.0
Added the ``capture`` parameter. The default ``sys`` mode no longer
exposes the original fd through :meth:`fileno`, reverting the change
introduced in ``8.3.3`` that broke Pytest's ``fd``-level capture
teardown. Use ``capture="fd"`` to restore that behavior with proper
isolation. :issue:`3384`
.. versionchanged:: 8.2
Added the ``catch_exceptions`` parameter.
.. versionchanged:: 8.2
``mix_stderr`` parameter has been removed.
NcóÆ|dvrtd|d«|dk(r"tjdk(rtd|d«||_|xsi|_||_||_||_y)N>rr
zcapture=z) is not valid. Choose from 'sys' or 'fd'.rÚwin32z( is not supported on Windows. Use 'sys'.)Ú
ValueErrorr
ÚplatformrŒÚenvÚ
echo_stdinÚcatch_exceptionsÚcapture)rs rrzCliRunner.__init__Ds~ð ˜ Ø˜7˜+Ð%NÐð
ð dŠ?œsŸ|™|¨wÒØ˜7˜+Ð%MÐð
ðˆŒ Ø25²)¸ˆŒØŒØ 0ˆÔØ$+ˆ rcó"|jxsdS)zžGiven a command object it will return the default program name
for it. The default is the `name` attribute or ``"root"`` if not
set.
Úroot)r|)rÚclis rÚget_default_prog_namezCliRunner.get_default_prog_nameZsð
x‰xÒ!˜!rcóVt|j«}|r|j|«|S)z8Returns the environment overrides for invoking a script.)Údictr®Úupdate)rÚ overridesr#s rÚmake_envzCliRunner.make_envas%ô$—(‘(‹^ˆÙ Ø I‰I ؈ rc#ó@ Kt||j«}d}tj}tj}tj
}t j} dt _|j|«}t«}
|jr:tjtjt||
j««x}}t||jdd¬«xt_Š|jrd_t|
j|jdd¬«t_t|
j
|jd dd
¬ «t_t#|«ddˆfd
«} t#|«ddˆfd
«} t#|«dd«}
|Š d dˆfd
}t$j&}t$j(}t$j*}t,j.}t0j.}t2j4j6Š| t$_| t$_|
t$_|t,_|t0_ d dˆfd
}|t2j4_i} |j9«D]O\}}t:j<j?|«||<| t:j<|=Œ=|t:j<|<ŒQ|
j|
j
|
jBf|j9«D]-\}}| t:j<|=Œ|t:j<|<Œ/|t_|t_|t_|t$_|t$_|t$_|t,_|t0_| t _t2j4_y#t@$rYŒ<wxYw#t@$rYŒÄwxYw#|j9«D]<\}}|€" t:j<|=Œ#t@$rYŒ&wxYw|t:j<|<Œ>|t_|t_|t_|t$_|t$_|t$_|t,_|t0_| t _t2j4_wxYw­w)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.
.. versionadded:: 8.2
An additional output stream is returned, which is a mix of
`<stdout>` and `<stderr>` streams.
.. versionchanged:: 8.2
Always returns the `<stderr>` stream.
.. versionchanged:: 8.0
`<stderr>` is opened with ``errors="backslashreplace"``
instead of the default ``"strict"``.
.. versionchanged:: 4.0
Added the ``color`` parameter.
NéPz<stdin>Úr)Úencodingr|r}rz<stdout>Úwz<stderr>Úbackslashreplace)r|r}Úerrorscó<tjj|xsd« t«j d«}tjj|d«tjj«|S#t
$r}t
«|d}~wwxYw)r)r
rsr"ÚnextÚrstripÚ
StopIterationÚEOFErrorrh)ÚpromptÚvalÚ
text_inputs €rÚ
visible_inputz*CliRunner.isolation.<locals>.visible_input¶s~ø€ä J‰J× Ñ ˜Vš\ rÔ 
˜&×-¨fÓ5ô
J‰J× Ñ  ˜u B˜ZÔ J‰J× Ñ Ô ØˆJøô 
“j 'ûð
(ús¦BÂ BÂ BÂBcóútjj|xsdd«tjj« t «j d«S#t $r}t«|d}~wwxYw)NrÃr)r
rsr"rh)s €rÚ hidden_inputz)CliRunner.isolation.<locals>.hidden_inputÁseø€ä J‰J× Ñ  ¢ ¨"˜~¨RÐ J‰J× Ñ Ô ð
˜'×.¨vÓ6øÜ ò
“j 'ûð
(úsÁA!Á! A:Á* A5Á5A:cóÂtjjd«}|rtjj |«tjj «|S)Nr)r
Ústdinr&rsr"rh)ÚechoÚchars rÚ_getcharz%CliRunner.isolation.<locals>._getcharÊs>ä—99—>> $ˆÜ
× Ñ  Ô J‰J× Ñ Ô ØˆKrcó| S| SrrE)rGÚcolorÚ
default_colors €rÚshould_strip_ansiz.CliRunner.isolation.<locals>.should_strip_ansiÖsø€ðˆ}Ø rcóh|tj}|tj}|f|||dœ|¤Žy)abDefault ``pdb.Pdb`` to real terminal streams during
``CliRunner`` isolation.
Without this patch, ``pdb.Pdb.__init__`` inherits from
``cmd.Cmd`` which falls back to ``sys.stdin``/``sys.stdout``
when no explicit streams are provided. During isolation
those are ``BytesIO``-backed wrappers, so the debugger
reads from an empty buffer and writes to captured output,
making interactive debugging impossible.
By defaulting to ``sys.__stdin__``/``sys.__stdout__`` (the
original terminal streams Python preserves regardless of
redirection), debuggers can interact with the user while
``click.echo`` output is still captured normally.
This covers ``pdb.set_trace()``, ``breakpoint()``,
``pdb.post_mortem()``, and debuggers that subclass
``pdb.Pdb`` (ipdb, pdbpp). Explicit ``stdin``/``stdout``
arguments are honored and not overridden. Debuggers that
do not subclass ``pdb.Pdb`` (pudb, debugpy) are not
covered.
N)Ú completekeyrÐrs)r
Ú __stdin__Ú
__stdout__)rrsr~Ú old_pdb_inits €rÚ_patched_pdb_initz.CliRunner.isolation.<locals>._patched_pdb_inités@ø€ð:ˆŸ
؈~ÜŸÙ Øð
Ø"-°UÀ6ñ
ØMSó
rr)z
str | Noner:r<)Úboolr:r<)NN)rGzt.IO[t.Any] | NonerÕú bool | Noner:)ÚtabNN) rzpdb.PdbrÙr<út.IO[str] | Nonersr~r=r:r;)"rr
rsrtrÚ FORCED_WIDTHrºror‡rˆÚBinaryIOrrvÚ _CHUNK_SIZErHrÚvisible_prompt_funcÚhidden_prompt_funcrÓr r×rÚpdbÚPdbrÚitemsrSÚenvironÚgetÚ Exceptionr)rrÚ bytes_inputÚ
echo_inputÚ old_stdinÚ
old_stdoutÚ
old_stderrÚold_forced_widthÚ stream_mixerrÌr×Úold_visible_prompt_funcÚold_hidden_prompt_funcÚold__getchar_funcÚold_should_strip_ansiÚold__compat_should_strip_ansirÝÚold_envÚkeyÚvaluerÖs @@@rÚ isolationzCliRunner.isolationjs)úèø€ôD¨t¯|©|Ó<ˆ ؈
ä—IIˆ Ü—ZZˆ
Ü—ZZˆ
Ü%ר"$Œ
Ôàm‰m˜CÓ ˆä"“}ˆ à ?Š?Ü'(§v¡vÜ
œL¨°l×6IÑ6IÓ(ð
ˆK˜"5Ø  $§,¡,°YÀSô"
ð
ŒŒ  ?Š?ð&'ˆ  × Ñ Ø—\‘\ØØô 
ŒŒ
ô × Ñ Ø—\‘\ØØØ 
ŒŒ
ô
ZÓ õ ó
 ô
ZÓ õ

ZÓ ò ó
 ðˆ
ðEIð Ø Ø6Að à
õ ô#)×"<Ñ"<ÐÜ!'×!:Ñ!:ÐÜ"ŸO™OÐÜ %× 7Ñ 7ÐÜ(/×(AÑ(AЗww×'ˆ Ø%2ŒÔ"Ø$0ŒÔŒØ"3ŒÔØ$5ŒÔ %Ø&*Ø'+ð # Øð# àð# ð# ð%ð # ð
ð # ð õ
# ðJÔàˆð!Ÿi™i›kò
,
!Ÿz™zŸ~™~¨cÓ2˜ ØÜŸJ™J s™Oð',”B—JJ˜s
 × ×(;Ñ(;¸\×=PÑ=PÐ %Ÿm™m
,
ÜŸJ™J s™Oð',”B—JJ˜s
$ŒCŒJØ#ŒCŒJØ!ŒCŒIØ)@ŒFÔ &Ø(>ŒFÔ /ŒFŒOØ&;ŒEÔ #Ø(EŒGÔ %Ø&6ŒJÔ +ŒCG‰GÕ øô/ÚðûôÙðûð &Ÿm™m
,
ÜŸJ™J s™OøÜÙðúð',”B—JJ˜s
$ŒCŒJØ#ŒCŒJØ!ŒCŒIØ)@ŒFÔ &Ø(>ŒFÔ /ŒFŒOØ&;ŒEÔ #Ø(EŒGÔ %Ø&6ŒJÔ +ŒCG‰GÕ üsŒ…I-RÉ3:OÊ.N3Ê?;OË:RÌOÌ$BRÎ3 OÎ<OÎ?OÏOÏ OÏ RÏOÏRÏRÏ,O>Ï=RÏ> P
ÐRÐ P
Ð
BRÒRc
ó¨d}| |j}d} d}
|jdk(r7td«} td«}
| j«|
j«|j |||¬«5} | @|
>| j tj_ |
j tj_ d} d}
d}t|t«rtj|«} |jd«} |j$d|xsd|d œ|¤Ž} tjj7«tjj7«| N|
L| j9«}|
j9«}|r| dj3|«|r| dj3|«| dj;«}| dj;«}| dj;«} ddd«t=| 
|¬ «S#t$rdx} }
YŒŸwxYw#t $r|j#|«}YŒ,wxYw#t&$r¥}tj(«}t+j,d
|j.«}|d}|dk7r|}
t|t0«sItjj3t|««tjj3d «d}|}Yd}~Œ¿d}~wt4$r&}|s|}
d}tj(«}Yd}~Œìd}~wwxYw#tjj7«tjj7«| N|
L| j9«}|
j9«}|r| dj3|«|r| dj3|«| dj;«}| dj;«}| dj;«}wxYw#1swYŒúxYw)
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.