a }|g@sdZddlmZddlZddlZddlmZddlZddlm Z ddl Z ddl m Z ddl m Z ddlmmZz ddlZWn*eyddlmmmZYn0Gdd d ejZd d Zed kree ejd degdS)z)Test certbot._internal.display.completer.)reloadN)List)mock) filesystem)oscseZdZdZfddZddZejdej vddd d Z d d Z e j d ddddZe j d ddddZddZZS) CompleterTestz3Test certbot._internal.display.completer.Completer.c st|jdtjkr*|jtj7_g|_tjD]b}tj |j|}|j |t |drnt |q6t|dWdq61s0Yq6dS)Nw)supersetUptempdirrseppathsstringZascii_lowercasepathjoinappendordrmkdiropen)selfcr __class__R/usr/lib/python3.9/site-packages/certbot/_internal/tests/display/completer_test.pyr s      zCompleterTest.setUpcCsddlm}|}t|j}t|D],}||j|}||jvsFJ|j|q&t|jdksfJ||j|}|dusJdSNr completer) certbot._internal.displayr CompleterlenrrangeZcompleter remove)rrZ my_completerZ num_pathsiZ completionrrr test_complete,s   zCompleterTest.test_completereadlinez*Not relevant if readline is not available.)reasoncCs*tjd}dtjd<||tjd<dS)Nr')sysmodules+test_context_manager_with_unmocked_readline)rZoriginal_readlinerrrtest_import_error:s  zCompleterTest.test_import_errorcCspddlm}t|t}t}|Wdn1sB0Yt|ks\Jt|kslJdSr)r r reload_moduler'Z get_completerZget_completer_delimsr!)rrZoriginal_completerZoriginal_delimsrrrr+Ds  z9CompleterTest.test_context_manager_with_unmocked_readlinez,certbot._internal.display.completer.readlineT)ZautospeccCsd|_||dS)Nlibedit__doc__(_test_context_manager_with_mock_readliner mock_readlinerrrtest_context_manager_libeditQsz*CompleterTest.test_context_manager_libeditcCsd|_||dS)Nz GNU readliner/r2rrrtest_context_manager_readlineVsz+CompleterTest.test_context_manager_readlinecCsPddlm}t|j_|Wdn1s20Y|jjdusLJdS)NrrT)r renable_tab_completionparse_and_bindZ side_effectr!Zcalled)rr3rrrrr1[s   z6CompleterTest._test_context_manager_with_mock_readline)__name__ __module__ __qualname__r0r r&unittestZskipIfr)r*r,r+rZpatchr4r5r1 __classcell__rrrrrs       rcCs.tjduodtjv}|rdnd}t|dS)zAEnables readline tab completion using the system specific syntax.Nr.zbind ^I rl_completez tab: complete)r'r0r7)Zunused_commandr.Zcommandrrrr6fs r6__main__) r0 importlibrr-rr)typingrr;rZpytestZcertbot.compatrrZcertbot.tests.utilZtestsutilZ test_utilr' ImportErrorZ(certbot._internal.display.dummy_readlineZ _internalZdisplayZdummy_readlineZTempDirTestCaserr6r8exitmainargv__file__rrrrs$       P