python (3.12.0)

(root)/
lib/
python3.12/
test/
__pycache__/
test_readline.cpython-312.pyc

Αe8dZddlmZddlmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZddlmZmZmZddlmZed	Zeed
rdej0vZnejxrdejvZd
Zej6eeddGddej8ZGddej8ZddZe dk(rejByy)z:
Very minimal unittests for parts of the readline module.
)	ExitStack)EION)verbose)
import_module)unlinktemp_dirTESTFN)assert_python_okreadline_READLINE_LIBRARY_VERSIONzEditLine wrapperlibeditc"trttdr:tdtjdtdtj
dttdrtdtjtdtyy)N_READLINE_VERSIONzreadline version: z#xzreadline runtime version: rzreadline library version: zuse libedit emulation? )rhasattrrprintr_READLINE_RUNTIME_VERSIONris_editlineF/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/test/test_readline.pysetUpModulers|801&x'A'A"&EFG.x/Q/QRT.UVW889.x/Q/Q.TUV
'}56r
clear_historyzXThe history update test cannot be run because the clear_history method is not available.c\eZdZdZdZejeedddZ	dZ
y)TestHistoryManipulationz
    These tests were added to check that the libedit emulation on OSX and the
    "real" readline have the same interface for history manipulation. That's
    why the tests cover only a small subset of the interface.
    ctjtjdtjd|jtj	dd|jtj	dd|jtj	ddtjdd|jtj	dd|jtj	dd|jtj	dd|jtj
dtjd|jtj	dd|jtj	dd|jtj
dy)N
first linesecond linerz
replaced line)rradd_historyassertEqualget_history_itemreplace_history_itemget_current_history_lengthremove_history_item)selfs rtestHistoryUpdatesz*TestHistoryManipulation.testHistoryUpdates1sR \*]+2215t<2215|D2215}E%%a92215t<2215G2215}E<<>B$$Q'2215t<2215}E<<>Brappend_history_filezappend_history not availablectjd}|j|j}|j	t
|tjtjdtjdtj|tj|jtjdtj||jtjd|jtjdd|jtjddtjd|tjtj||jtjd|jtjdd|jtjdd|jtjddtj
|	tjd|tj
|tj|y#t $rY!wxYw)	NF)deleterrrrr)tempfileNamedTemporaryFileclosename
addCleanuprrrr write_history_filer!r$read_history_filer"r(osFileNotFoundError)r&hfile	hfilenames   rtest_write_read_appendz.TestHistoryManipulation.test_write_read_appendHs++59

JJ		*	 \*]+##I. <<>B""9-<<>B2215|D2215}E	$$Q	2 ""9-<<>B2215|D2215}E2215}E			)	!((I6
IIi 	##I.!		s?J	JJctj	tjdtjdtj
ddtjt|jtjttjtjttrtjd|jtjdd|jtjddy#t$r(}|j	dt|zYd}~'d}~wwxYw)Nu	entrée 1 Locale cannot encode test data: u	entrée 2ru
entrée 22dummyr)rrr UnicodeEncodeErrorskipTestformatr#r1r	r0r3remover2rr!r")r&errs  rtest_nonascii_historyz-TestHistoryManipulation.test_nonascii_historyvs 	L  -	[)%%a6##F+		6* ""6*
  )2215{C2215|D"	LMM<vc{JKK	LsD&&	E/EEN)__name__
__module____qualname____doc__r'unittest
skipUnlessrrr7r@rrrrr'sBC.X+@A79*/9*/XErrceZdZejejdkxreddZdZ	dZ
dZdZejejdkd	ejed
dZ
y)
TestReadlineiz%not supported in this library versioncLtddd\}}}|j|dy)N-czimport readlinezxterm-256color)TERMr)r
r!)r&rcstdoutstderrs    r	test_initzTestReadline.test_inits..d4E3CEFF%rzvimport readline
readline.set_auto_history({})
input()
print("History length:", readline.get_current_history_length())
cpt|jjd}|jd|y)NTsHistory length: 1run_ptyauto_history_scriptr=assertInr&outputs  rtest_auto_history_enabledz&TestReadline.test_auto_history_enableds.1188>?	


*F3rcpt|jjd}|jd|y)NFsHistory length: 0rQrUs  rtest_auto_history_disabledz'TestReadline.test_auto_history_disableds.1188?@	


*F3rctjtjd}|dvr|jd|	tjdd}d}|dtdzz
}|d	z
}|d
z
}|dz
}t||}|jd||jd
|tjdk(sts|jd|ts4ttdr$|jd||jd|d}|jd|zdz||jd|z|y#t$r(}|jdt|zYd}~d}~wwxYw)N)CPOSIXzthe LC_CTYPE locale is uëïr9a*import readline

is_editline = readline.__doc__ and "libedit" in readline.__doc__
inserted = "[\xEFnserted]"
macro = "|t\xEB[after]"
set_pre_input_hook = getattr(readline, "set_pre_input_hook", None)
if is_editline or not set_pre_input_hook:
    # The insert_line() call via pre_input_hook() does nothing with Editline,
    # so include the extra text that would have been inserted here
    macro = inserted + macro

if is_editline:
    readline.parse_and_bind(r'bind ^B ed-prev-char')
    readline.parse_and_bind(r'bind "\t" rl_complete')
    readline.parse_and_bind(r'bind -s ^A "{}"'.format(macro))
else:
    readline.parse_and_bind(r'Control-b: backward-char')
    readline.parse_and_bind(r'"\t": complete')
    readline.parse_and_bind(r'set disable-completion off')
    readline.parse_and_bind(r'set show-all-if-ambiguous off')
    readline.parse_and_bind(r'set show-all-if-unmodified off')
    readline.parse_and_bind(r'Control-a: "{}"'.format(macro))

def pre_input_hook():
    readline.insert_text(inserted)
    readline.redisplay()
if set_pre_input_hook:
    set_pre_input_hook(pre_input_hook)

def completer(text, state):
    if text == "t\xEB":
        if state == 0:
            print("text", ascii(text))
            print("line", ascii(readline.get_line_buffer()))
            print("indexes", readline.get_begidx(), readline.get_endidx())
            return "t\xEBnt"
        if state == 1:
            return "t\xEBxt"
    if text == "t\xEBx" and state == 0:
        return "t\xEBxt"
    return None
readline.set_completer(completer)

def display(substitution, matches, longest_match_length):
    print("substitution", ascii(substitution))
    print("matches", ascii(matches))
readline.set_completion_display_matches_hook(display)

print("result", ascii(input()))
print("history", ascii(readline.get_history_item(1)))
z[after]s		sx	
stext 't\xeb'
s#line '[\xefnserted]|t\xeb[after]'
darwinsindexes 11 13
set_pre_input_hookssubstitution 't\xeb'
s matches ['t\xebnt', 't\xebxt']
s'[\xefnserted]|t\xebxt[after]'sresult s
shistory )locale	setlocaleLC_CTYPEr<rr r;r=lenrRrTsysplatformrr)r&locr?scriptinputrVexpecteds       r
test_nonasciizTestReadline.test_nonasciis\v5. 
MM3C7;<	L  ,2h
3y>))


'

*F3

@&I<<8#;MM.7wx1EFMM6?MMA6J5

j8+g5v>	


kH,f5c"	LMM<vc{JKK	LsD<<	E-E((E-iz3this readline version does not support history-sizez-editline history size configuration is brokenc	"d}t5}tjj|d}t	|d5}|jd|zdddtjj|d}t	|d5}djdt
|dzD}|j|dddd	}ttj}||d
<||d<t|d|
t	|d5}|j}	ddd|jt	||j|	djddddy#1swYxYw#1swYxYw#1swYixYw#1swYyxYw)N
inputrcwbsset history-size %d
historyrc3&K|]	}d|zyw)sitem %d
Nr).0is  r	<genexpr>z1TestReadline.test_history_size.<locals>.<genexpr>s B$%!-q 0 Bsrz
import os
import readline

history_file = os.environ["HISTORY_FILE"]
readline.read_history_file(history_file)
input()
readline.write_history_file(history_file)
INPUTRCHISTORY_FILEslast input
)rjenvrbs
last input)rr3pathjoinopenwriterangedictenvironrR	readlinesr!restrip)
r&history_sizetest_dirrofhistory_filedatarirxliness
          rtest_history_sizezTestReadline.test_history_sizesp

Z	?8ggll8Y7Ggt$
A0<?@
A77<<)<LlD)
Qxx B).|a/?)@ BB
	
Frzz"C$C	N".CF/s;lD)
&Q

&SZ6U2Y__.
>?	?	?
A
A

,
&
&9	?	?sT-FE 4F6E-9AFE9AF E*	%F-E6	2F9F	>FFN)rArBrCrEskipIfrrrrOrSrWrYrlrrrrrHrHsX__X//&8L_<>&>&44[6DX__X//%7JLX__[DF!?FL!?rrHc~td}t}|j\}}tjd|f}tj|||||}tj|t5}	|	j|d}
|	j|
||	jtj||	jtj}|j|tjtj ztj"|d	|j%D]\}}
|
tjzr7	tj&|d}|s
|ccdddS|j/||
tj zsd	|tj0||d}|r|j3|tj#t($r }|j*t,k7rd}Yd}~d}~wwxYw#t($r }|j*t,k7rd}Yd}~vd}~wwxYw#1swYyxYw)NptyrJ)stdinrMrNrxcD	|jy#t$rYywxYw)N)	terminateProcessLookupError)procs rrzrun_pty.<locals>.terminate<s#
 %

s	Fir)r	bytearrayopenptyrf
executable
subprocessPopenr3r.r
enter_contextcallback	selectorsSelectSelectorregister
EVENT_READEVENT_WRITEset_blockingselectreadOSErrorerrnorextendr~modify)rirjrxrrVmasterslaveargsrcleanuprsel_eventschunkr?s                rrRrR3s

C
[FkkmOVUNND&)DDeEsSDHHUO	(Ad#		D)6*##I$<$<$>?VY11I4I4IIJ
&"zz|
AFI000$ " 8!%
;(A(A<MM%(I111$ %bhhvu&=&> ?!

69+?+?@+
A
#$99+! #	$#$99+! #	$E(A(Asm5CH3G'H36$H3H5H38#H3	H$G?:H3?HH3	H0H+&H3+H00H33H<__main__)sdummy input
N)"rD
contextlibrrrrbr3rrrfr,rEtest.supportrtest.support.import_helperrtest.support.os_helperrrr	test.support.script_helperr
rrrrrrFTestCaserrHrRrAmainrrr<module>rs!
	
 4;;7$
801%)K)KKK##E	X5E5E(EK	7WX7>?]Ex00]E?]E@f?8$$f?R/AdzHMMOr