
    h7                    `   S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK
r
SSKrSSKJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJr  SSK J!r!J"r"  SSK#J$r$  SSK%J&r&  SSK'J(r(  SSK)J*r*J+r+J,r,J-r-  SS	K.J/r/J0r0J1r1J2r2  SS
K3J4r4J5r5J6r6J7r7J8r8J9r9  SSK:J;r;J<r<J=r=J>r>  SSK?J@r@JArAJBrBJCrCJDrDJErEJFrFJGrGJHrHJIrIJJrJJKrKJLrLJMrMJNrNJOrOJPrPJQrQJRrR  SSKSJTrT  SSKUJVrVJWrW  SSKXJYrYJZrZJ[r[J\r\J]r]J^r^J_r_J`r`JaraJbrbJcrc  SSKdJereJfrfJgrgJhrhJiriJjrjJkrkJlrl  SSKmJnrnJoroJprpJqrq  SSKrJsrs   " S S\_5      rtSS jrug)z+Test suite for the `humanfriendly` package.    N)InvalidDateInvalidLengthInvalidSizeInvalidTimespanTimercoerce_booleancoerce_patternformat_lengthformat_numberformat_pathformat_sizeformat_timespan
parse_dateparse_length
parse_path
parse_sizeparse_timespanpromptsround_number)CaseInsensitiveDictCaseInsensitiveKey)main)StringIOcached)DeprecationProxydefine_aliasesdeprecated_argsget_aliases)TooManyInvalidRepliesprompt_for_confirmationprompt_for_choiceprompt_for_input)deprecation_note_callbackman_role	pypi_rolesetupspecial_methods_callbackusage_message_callback)format_pretty_tableformat_robust_tableformat_rst_tableformat_smart_table)ANSI_CSIANSI_ERASE_LINEANSI_HIDE_CURSOR
ANSI_RESETANSI_SGRANSI_SHOW_CURSOR
ansi_strip
ansi_style
ansi_width	ansi_wrapclean_terminal_outputconnected_to_terminalfind_terminal_sizeget_pager_commandmessageoutput
show_pagerterminal_supports_colorswarninghtml_to_ansi)AutomaticSpinnerSpinner)CallableTimedOutCaptureOutputMockedProgramPatchedAttributePatchedItemTemporaryDirectoryTestCaseretryrun_cliskip_on_raisetouch)compactcompact_empty_linesconcatenatededentgenerate_slug	pluralizerandom_stringtrim_empty_lines)find_meta_variablesformat_usageparse_usagerender_usage)	MagicMockc                      \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S  r"S! r#S" r$S# r%S$ r&S% r'S& r(S' r)S( r*S) r+S* r,S+ r-S, r.S- r/S. r0S/ r1S0 r2S1 r3S2 r4S3 r5S4 r6S5 r7S6 r8S7 r9S8 r:S9 r;S: r<S; r=S< r>S= r?S> r@S? rAS@ rBSA rCSB rDSC rESD rFSE rGSF rHSG rISH rJSI rKSJ rLSK rMSLrNgM)NHumanFriendlyTestCase   z-Container for the `humanfriendly` test suite.c           	      T   [        [        SS/5      5      S:X  d   e[        [        SS/SSS95      S	:X  d   e[        [        [        SSS
95      5      S:X  d   e[        [        [        SSS9SSS95      S	:X  d   e[        [        SSSS95      S	:X  d   e[        R                  " / SQ5      n[        U5      S	:X  d   e[        SS9nUR	                  S5      S:X  d   e[        SS9nUR                  S5      S:X  d   e[        U5      S:X  d   e[        SS9nUR                  S5      S:X  d   eUR                  SS5        US   S:X  d   e[        SS9nSU;   d   e[        SS9nUS	 [        U5      S:X  d   e[        SS9nUS   S:X  d   e[        SS9nSUS'   US   S:X  d   eg)z#Test the CaseInsensitiveDict class.)keyT)KEYF   )oneT)ONEFFT)rd   two   )ra   rb   )rd   re   )rd   re   rf   )Onerd   re   Tworf   TWO*   )existing_keyExisting_Keyr   	other_key   	Other_Keyrl   N)lenr   dictfromkeysgetpop
setdefault)selfobjs     M/var/www/fran/franai/venv/lib/python3.13/site-packages/humanfriendly/tests.pytest_case_insensitive_dict0HumanFriendlyTestCase.test_case_insensitive_dict   s    &~'FGHAMMM&~'FEW[\]abbbb&t%'@ABaGGG&t%'@eQUVW[\\\\&4UEF!KKK!**+UV3x1}}!r2ww~&",,,!r2ww~&",,,3x1}}!r2~~n-333{B';2%%%!r2$$$!r23x1}}!r2>"b(((!r2 N>"b(((    c                 t    [        S5      n[        S5      nX:X  d   e0 nSX1'   SX2'   [        U5      S:X  d   eg)z"Test the CaseInsensitiveKey class.zPlease don't shoutzPLEASE DON'T SHOUTrc   rg   N)r   rq   )rw   politerudemappings       ry   test_case_insensitive_key/HumanFriendlyTestCase.test_case_insensitive_key   sI     $$89!"67~~7|q   r|   c                 N   [        5        n[        R                  R                  S5        [        R                  R                  S5        UR                  R                  5       S/:X  d   eUR                  R                  5       S/:X  d   e SSS5        g! , (       d  f       g= f)zTest the CaptureOutput class.zSomething for stdout.
zAnd for stderr.
zSomething for stdout.zAnd for stderr.N)rF   sysstdoutwritestderr	get_lines)rw   capturers     ry   test_capture_output)HumanFriendlyTestCase.test_capture_output   sw    _JJ67JJ01??,,.3J2KKKK??,,.3D2EEEE	 __s   BB
B$c                     S n[        [        5      nU" U5      nU R                  [        U5        U R                  [        R                  U5        g)z#Test the skip_on_raise() decorator.c                      [        5       eN)NotImplementedError r|   ry   test_fn9HumanFriendlyTestCase.test_skip_on_raise.<locals>.test_fn   s    %''r|   N)rN   r   assertRaisesunittestSkipTest)rw   r   decorator_fndecorated_fns       ry   test_skip_on_raise(HumanFriendlyTestCase.test_skip_on_raise   sC    	($%89#G,-w7(++\:r|   c                    ^ U4S jm[        T5      S:X  d   eS nU R                  [        5         [        USS9  SSS5        g! , (       d  f       g= f)zFTest :func:`~humanfriendly.testing.retry()` based on assertion errors.c                  F   > [        T S5      (       d  [        T SS5         eg)N
was_calledTyeshasattrsetattrsuccess_helpers   ry   r   >HumanFriendlyTestCase.test_retry_raise.<locals>.success_helper   s$    ><88d;ur|   r   c                       er   r   r   r|   ry   failure_helper>HumanFriendlyTestCase.test_retry_raise.<locals>.failure_helper   s    5r|   rc   timeoutN)rL   r   AssertionError)rw   r   r   s     @ry   test_retry_raise&HumanFriendlyTestCase.test_retry_raise   sF    	 ^$---	~..!, /..s   A
Ac                    ^ U4S jm[        T5      S:X  d   eU R                  [        5         [        S SS9  SSS5        g! , (       d  f       g= f)zCTest :func:`~humanfriendly.testing.retry()` based on return values.c                  D   > [        T S5      (       d  [        T SS5        gg)Nr   TFrk   r   r   s   ry   r   ?HumanFriendlyTestCase.test_retry_return.<locals>.success_helper   s$    ><88d; r|   rk   c                      g)NFr   r   r|   ry   <lambda>9HumanFriendlyTestCase.test_retry_return.<locals>.<lambda>   s    %r|   rc   r   N)rL   r   rE   )rw   r   s    @ry   test_retry_return'HumanFriendlyTestCase.test_retry_return   sB    	 ^$***/0-+ 100s   A
Ac                 4   [        5       n[        S5      n[        USUS9 n[        R                  R                  U5      (       d   e[        R                  R                  [        R                  R                  X15      5      (       d   e[        R                  " U[        R                  [        R                  [        R                  S9nUR                  SS9u  pVUR                  S:X  d   eUS:X  d   eUS:X  d   e S	S	S	5        g	! , (       d  f       g	= f)
z2Test :class:`humanfriendly.testing.MockedProgram`.z
            # This goes to stdout.
            tr a-z A-Z
            # This goes to stderr.
            echo Fake warning >&2
        rk   )name
returncodescript)stdinr   r   s   hello world
inputs   HELLO WORLD
s   Fake warning
N)rV   rS   rG   ospathisdirisfilejoin
subprocessPopenPIPEcommunicater   )rw   r   r   	directoryprogramr   r   s          ry   test_mocked_program)HumanFriendlyTestCase.test_mocked_program   s       FCy77==++++77>>"'',,y"?@@@@ &&t:??:??cmcrcrsG$007G0HNF%%+++----.... DCCs   CD		
Dc                    [        5        n[        R                  R                  U5      (       d   e[        R                  R	                  US5      n[        US5       nUR                  S5        SSS5        SSS5        [        R                  R                  W5      (       a   e[        R                  R                  W5      (       a   eg! , (       d  f       Nc= f! , (       d  f       Nl= f)z7Test :class:`humanfriendly.testing.TemporaryDirectory`.z	some-filewzHello world!N)rJ   r   r   r   r   openr   exists)rw   r   temporary_filehandles       ry   test_temporary_directory.HumanFriendlyTestCase.test_temporary_directory   s    !Y77==++++WW\\)[ANnc*f^, + "
 77>>.111177>>),,,,, +* "!s$   ACC0C
C	C
C,c                 \   [        5        n[        R                  R                  U[	        5       5      n[        R                  R                  U5      (       a   e[        U5        [        R                  R                  U5      (       d   e[        R                  R                  U[	        5       [	        5       5      n[        R                  R                  U5      (       a   e[        U5        [        R                  R                  U5      (       d   e SSS5        g! , (       d  f       g= f)z+Test :func:`humanfriendly.testing.touch()`.N)rJ   r   r   r   rV   r   rO   )rw   r   filenames      ry   
test_touch HumanFriendlyTestCase.test_touch
  s    !Yww||I}?Hww~~h////(O77>>(++++ww||I}PHww~~h////(O77>>(++++ "!!s   DD
D+c                      " S S[         5      nU" 5       nUR                  S:X  d   e[        USS5       nX2L d   eUR                  S:X  d   e SSS5        UR                  S:X  d   eg! , (       d  f       N!= f)z5Test :class:`humanfriendly.testing.PatchedAttribute`.c                       \ rS rSrSrSrg);HumanFriendlyTestCase.test_patch_attribute.<locals>.Subjecti  rk   r   N)__name__
__module____qualname____firstlineno__my_attribute__static_attributes__r   r|   ry   Subjectr     s    Lr|   r   rk   r      N)objectr   rH   )rw   r   instancereturn_values       ry   test_patch_attribute*HumanFriendlyTestCase.test_patch_attribute  s{    	f 	9$$***h;|+++((B... < $$*** <;s   A++
A9c                     [        SS9nUS   SL d   e[        USS5       nX!L d   eUS   SL d   e SSS5        US   SL d   eg! , (       d  f       N= f)z0Test :class:`humanfriendly.testing.PatchedItem`.T)my_itemr   FN)rr   rI   )rw   r   r   s      ry   test_patch_item%HumanFriendlyTestCase.test_patch_item#  so    %	"d***9e4+++I&%/// 5 	"d*** 54s   A
Ac                 D    [        S 5      u  pU R                  US5        g)z*Test that run_cli() intercepts SystemExit.c                  .    [         R                  " S5      $ )Nrk   )r   exitr   r|   ry   r   DHumanFriendlyTestCase.test_run_cli_intercepts_exit.<locals>.<lambda>.  s    SXXb\r|   rk   N)rM   assertEqualrw   r   r=   s      ry   test_run_cli_intercepts_exit2HumanFriendlyTestCase.test_run_cli_intercepts_exit,  s     $%9:
R(r|   c                 V    [        U R                  5      u  pU R                  US5        g)z*Test that run_cli() intercepts exceptions.rc   N)rM   run_cli_raise_otherr   r   s      ry   test_run_cli_intercepts_error3HumanFriendlyTestCase.test_run_cli_intercepts_error1  s%    $T%=%=>
Q'r|   c                     [        5       e)z*run_cli() sample that raises an exception.)
ValueErrorrw   s    ry   r   )HumanFriendlyTestCase.run_cli_raise_other6  s
    lr|   c                    ^ [        5       S-   m[        U4S j5      u  pU R                  US5        U R                  UT5        g)z&Test that run_cli() intercepts output.
c                  B   > [         R                  R                  T 5      $ r   )r   r   r   )expected_outputs   ry   r   FHumanFriendlyTestCase.test_run_cli_intercepts_output.<locals>.<lambda>=  s    SZZ-=-=o-Nr|   r   N)rV   rM   r   )rw   r   r=   r   s      @ry   test_run_cli_intercepts_output4HumanFriendlyTestCase.test_run_cli_intercepts_output:  s=    '/D0$%NO
Q'1r|   c                     [        S 5      n[        S 5      nU" 5       U" 5       :X  d   eU" 5       U" 5       :X  d   eU" 5       U" 5       :w  d   eg)zTest the caching decorator.c                  ,    [         R                   " 5       $ r   randomr   r|   ry   r   >HumanFriendlyTestCase.test_caching_decorator.<locals>.<lambda>D  
    6==?r|   c                  ,    [         R                   " 5       $ r   r  r   r|   ry   r   r  E  r  r|   Nr   )rw   abs      ry   test_caching_decorator,HumanFriendlyTestCase.test_caching_decoratorA  sJ     *+*+saczzsaczzsaczzr|   c                 j    [        S5      S:X  d   e[        SS5      S:X  d   e[        SSS9S	:X  d   eg
)z*Test :func:`humanfriendly.text.compact()`.z a 

 b za bz*
            %s template notation
        SimplezSimple template notationz3
            More {type} template notation
        readable)typezMore readable template notationN)rP   r   s    ry   test_compact"HumanFriendlyTestCase.test_compactK  s^    |$--- 45 	5 5  !BC 	C Cr|   c                     [        S5      S:X  d   e[        S5      S:X  d   e[        S5      S:X  d   e[        S5      S:X  d   e[        S5      S:X  d   e[        S5      S:X  d   e[        S5      S:X  d   eg)	z6Test :func:`humanfriendly.text.compact_empty_lines()`.fooz	foofoo
barzfoo

barz	foo


barz
foo



barzfoo




barN)rQ   r   s    ry   test_compact_empty_lines.HumanFriendlyTestCase.test_compact_empty_linesU  s     #5)U222"7+w666":.*<<<"<0L@@@">2lBBB"#34DDD"#56,FFFr|   c                 j    [        S5      S:X  d   e[        SS5      S:X  d   e[        SSS9S	:X  d   eg
)z)Test :func:`humanfriendly.text.dedent()`.z
 line 1
  line 2

zline 1
 line 2
z'
            Dedented, %s text
        interpolatedzDedented, interpolated text
z)
            Dedented, {op} text
        	formatted)opzDedented, formatted text
N)rS   r   s    ry   test_dedent!HumanFriendlyTestCase.test_dedentd  s`    /04GGGG  ?@ 	@ @   <= 	= =r|   c                     [        SS5      S:X  d   e[        SS5      S:X  d   e[        SSS5      S:X  d   e[        SSS5      S	:X  d   eg
)z,Test :func:`humanfriendly.text.pluralize()`.rc   wordz1 wordrg   z2 wordsboxboxesz1 boxz2 boxesN)rU   r   s    ry   test_pluralization(HumanFriendlyTestCase.test_pluralizationn  sZ    F#x///F#y000E7+w666E7+y888r|   c                 X   U R                  S[        S5      5        U R                  S[        S5      5        U R                  [        5         [        S5        SSS5        U R                  [        5         [        S5        SSS5        g! , (       d  f       N8= f! , (       d  f       g= f)z0Test :func:`humanfriendly.text.generate_slug()`.zsome-random-textzSome Random Text! N-)r   rT   r   r   r   s    ry   test_generate_slug(HumanFriendlyTestCase.test_generate_slugu  s{     	+];N-OP+];M-NOz*# +z*# +* +***s   B
5B

B
B)c                    S H  nU R                  S[        U5      5        M      S H  nU R                  S[        U5      5        M      U R                  [        5         [        S5        SSS5        g! , (       d  f       g= f)z,Test :func:`humanfriendly.coerce_boolean()`.)TTRUETruetrueonr   1T)FFALSEFalsefalseoffno0Fznot a booleanN)r   r   r   r   )rw   values     ry   test_boolean_coercion+HumanFriendlyTestCase.test_boolean_coercion  sd    EET>%#89 FIEUN5$9: Jz*?+ +**s   A33
Bc                 r   [         R                  " S5      n[        [        S5      [	        U5      5      (       d   eU[        U5      L d   e[        S[         R
                  5      nUR                  S5      (       d   eU R                  [        5         [        / 5        SSS5        g! , (       d  f       g= f)z,Test :func:`humanfriendly.coerce_pattern()`. foobarFOOBARN)	recompile
isinstancer	   r  
IGNORECASEmatchr   r   )rw   empty_patternpatterns      ry   test_pattern_coercion+HumanFriendlyTestCase.test_pattern_coercion  s    

2.2D4GHHHH} ==== 2==9}}X&&&&z*2 +**s   B((
B6c                 \   SnUS-  nUS-  nUS-  nUS-  nS[        SSS9:X  d   eS	[        S
SS9:X  d   eS[        SSS9:X  d   eS[        SSS9:X  d   eS[        SSS9:X  d   eS[        SSS9:X  d   eS[        SSS9:X  d   eS[        S5      :X  d   eS[        S5      :X  d   eS[        S5      :X  d   eS[        [        R                  5      :X  d   eS[        U5      :X  d   eS[        S5      :X  d   eS[        US -  5      :X  d   eS![        U5      :X  d   eS"[        US -  5      :X  d   eS#[        U5      :X  d   eS$[        US -  5      :X  d   eS%[        U5      :X  d   eS&[        US -  5      :X  d   eS'[        U5      :X  d   eS([        US -  5      :X  d   eS)[        US*-  US+-  -   US,-  -   US--  -   US -  -   S-   SS9:X  d   eS.[        XTS -  -   US--  -   US/-  -   5      :X  d   eS0[        S1SS9:X  d   eS2[        S1SS9:X  d   eS3[        S45      :X  d   eS5[        S65      :X  d   eS7[        S8SS9:X  d   eS9[        S:SS9:X  d   eS;[        S<SS9:X  d   e[        R                  R	                  5       nU[        R
                  " S=S>9-
  nS?[        Xg-
  5      :X  d   eg@)Az-Test :func:`humanfriendly.format_timespan()`.<         4   z1 nanosecond&.>T)detailedz500 nanosecondsgƠ>z1 microsecondư>z500 microsecondsgMb@?1 millisecondMbP?500 milliseconds      ?0.5 secondsFz	0 secondsr   z0.54 secondsgna?1 secondrc   z3.14 seconds1 minutez1 minute and 20 secondsP   	2 minutesrg   1 hour2 hours1 day2 days1 week2 weeksz1 yearz2 yearszA6 years, 5 weeks, 4 days, 3 hours, 2 minutes and 500 milliseconds            z1 year, 2 weeks and 3 days   z'1 minute, 1 second and 100 millisecondsǧN@z1 minute and 1.1 secondsz1 minute and 0.3 secondsgfffff&N@z5 minutes and 0.3 secondsgr@z1 second and 15 millisecondsg=
ףp=?z10 seconds and 15 millisecondsgHz$@z 1 microsecond and 50 nanosecondsgӋ5>   )hoursz23 hoursN)r   mathpidatetimenow	timedelta)rw   minutehourdayweekyearrc  thens           ry   test_format_timespan*HumanFriendlyTestCase.test_format_timespan  sN   {RiQwbyt!LLLL OI$MMMM/(T"JJJJ!_Vd%KKKK/%$"GGGG!_S4%HHHHe DDDDoa0000!9999_Q////!9999_V4444(OB,????ofqj9999?40000OD1H5555/#....?373333?40000OD1H5555?40000OD1H5555RD1Htax/#'9D1HDvPQzQTWWbfgh 	h h+D!8OcAg5r	ABC 	C C 9OE\`<aaaa)_UU-SSSS *_V-DDDD*og.FFFF-QU1VVVV/?6TX3YYYY1_ZZ^5____ ##%X''b11_SZ8888r|   c                    U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S	5      5        U R                  S
[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S 5      5        U R                  S![        S"5      5        U R                  S![        S#5      5        U R                  [        5         [        S$5        S%S%S%5        g%! , (       d  f       g%= f)&z,Test :func:`humanfriendly.parse_timespan()`.r   r1  0srG  1nsgbak>51nsrI  1usg'eRC?52usrK  1msrJ  rM  rL  rN  rZ  5sz	5 secondsx   2mrR     z3 minz3 minsi0*  z3 hz3 hoursi F 4dz4 daysi$. z5 wz5 weeks1zN)r   r   r   r   r   s    ry   test_parse_timespan)HumanFriendlyTestCase.test_parse_timespan  s   N3/0N401nU&;<nV&<=>%#89>&#9:u 56 ?@n-?@An];<N401N;78!56!<=!89!9:nU&;<nY&?@)>$+?@)>(+CD-~e/DE-~i/HI/4  0//s   (I==
Jc                    U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  [        5         [        S5        SSS5        g! , (       d  f       g= f)	z(Test :func:`humanfriendly.parse_date()`.)  rY     r   r   r   z
2013-06-17)r}  rY  r~  rg   /   rk   z2013-06-17 02:47:42)i  ro      r   r  r~  z2016-11-30 00:47:17z
2013-06-XYN)r   r   r   r   r   s    ry   test_parse_date%HumanFriendlyTestCase.test_parse_date  sh    /L1IJ1:>S3TU2J?U4VW{+|$ ,++s   'A<<
B
c                 b   U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S	[        S
5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        SSS95        U R                  S[        SSS95        U R                  S[        SSS95        U R                  S[        S SS95        U R                  S![        S"SS95        U R                  S#[        S$SS95        U R                  S%[        S&SS95        U R                  S'[        S(SS95        U R                  S)[        S*5      5        U R                  S+[        S,5      5        g-).z)Test :func:`humanfriendly.format_size()`.z0 bytesr   z1 byterc   z42 bytesrk   1 KB  z1 MB@B 1 GB ʚ;1 TB    J)1 PB     I5 1 EB     NZo1 ZB     @=7M.c1 YB      B3v^!< z1 KiB   Tbinaryz1 MiB   z1 GiBi   @z1 TiBl        z1 PiBl           z1 EiBl            z1 ZiBl            z1 YiBl               z45 KBiȯ  z2.9 TBg  @«BN)r   r   r   s    ry   test_format_size&HumanFriendlyTestCase.test_format_size  s   KN3;q>2[_5Y!78Y!78Y!78Y!78Y!78Y!78Y!78Y!78+i"EF+i"EF+i"EF+i"EF+i"EF+i"EF+i"EF+i"EF+i"89;#?@r|   c                 ~   U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        SS	S
95        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        SS	S
95        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  [        5         [        S5        S S S 5        U R                  [        5         [        S!5        S S S 5        g ! , (       d  f       N8= f! , (       d  f       g = f)"z(Test :func:`humanfriendly.parse_size()`.r   0Brk   4242Br  1kr  Tr  r  z
1 kilobytei@z69 MBr  r  r  r  r  r  r  r  r  r  r  r  g   ZAz1.5 GBg      Dz1.5 YiB1qNr  )r   r   r   r   r   s    ry   test_parse_size%HumanFriendlyTestCase.test_parse_size  s   Jt,-Z-.Z./z$/0z$t<=z&12z,78z,tDEG)<=Jv$67Jv$67Jv$67Jv$67Jv$67Jv$67*X*>?*Y*?@{+t ,{+sO ,+ ,+++s   HH.
H+.
H<c                    U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S	[        S
5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        g)z+Test :func:`humanfriendly.format_length()`.z0 metresr   z1 metrerc   z	42 metresrk   z1 kmr  15.3 cm/$?z1 cm{Gz?z1 mmrK  z1 nmrG  N)r   r
   r   s    ry   test_format_length(HumanFriendlyTestCase.test_format_length  s    ]1%56M!$45mB&78x!89M%$89u!56u!56u!56r|   c                    U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S	5      5        U R                  S
[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  [        5         [        S5        SSS5        U R                  [        5         [        S5        SSS5        g! , (       d  f       N8= f! , (       d  f       g= f)z*Test :func:`humanfriendly.parse_length()`.r   0mrk   r        ?1.542mr  1kmr  r  r  1cmrK  1mmrG  1nmry  Nr  )r   r   r   r   r   s    ry   test_parse_length'HumanFriendlyTestCase.test_parse_length(  s   L./\$/0l512\%01|E23Y 78U 34U 34U 34}- .}- .- .---s   	E2E
E
E&c                    U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        SS5      5        U R                  S	[        S
5      5        U R                  S	[        SS5      5        U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        S5      5        g)z+Test :func:`humanfriendly.format_number()`.r+  rc   r  r  z1.56gg?z1.567r\  z1,000r  g)\@@r   z	1,000,000r  z1,000,000.42gq=
׀.Az-285.67gQqN)r   r   r   s    ry   test_format_number(HumanFriendlyTestCase.test_format_number8  s    mA./c 23w!78-";<-"56-";<mG&<=z)BCM'$:;r|   c                     U R                  S[        S5      5        U R                  S[        S5      5        U R                  S[        SSS95        U R                  S[        S5      5        g	)
z*Test :func:`humanfriendly.round_number()`.r+  rc   g      ?1.00T
keep_widthz3.14g-DT!	@N)r   r   r   s    ry   test_round_number'HumanFriendlyTestCase.test_round_numberE  sX    l1o.l3/0aD!AB.?!@Ar|   c                     [         R                  R                  SS5      n[         R                  R                  [         R                  S   S5      nU R	                  U[        U5      5        g)z)Test :func:`humanfriendly.format_path()`.~.vimrcHOMEN)r   r   r   environr   r   rw   friendly_pathabsolute_paths      ry   test_format_path&HumanFriendlyTestCase.test_format_pathL  sH    S(3RZZ%7BM(BCr|   c                     [         R                  R                  SS5      n[         R                  R                  [         R                  S   S5      nU R	                  U[        U5      5        g)z(Test :func:`humanfriendly.parse_path()`.r  r  r  N)r   r   r   r  r   r   r  s      ry   test_parse_path%HumanFriendlyTestCase.test_parse_pathR  sH    S(3RZZ%7B
=(ABr|   c                    S//n[        U5      [        S5      R                  5       :X  d   e/ SQ/ SQ/n[        U5      [        S5      R                  5       :X  d   e/ SQn/ SQ/ SQ/n[        [        X5      5      [        S5      R                  5       :X  d   eSS	/nS
S/SS//n[        [        X5      5      [        S5      R                  5       :X  d   eg)z8Test :func:`humanfriendly.tables.format_pretty_table()`.zJust one columnzi
            -------------------
            | Just one column |
            -------------------
        rh   ri   Threer+  23z
            ---------------------
            | One | Two | Three |
            | 1   | 2   | 3     |
            ---------------------
        r  r  c
            ---------------------
            | One | Two | Three |
            ---------------------
            | 1   | 2   | 3     |
            | a   | b   | c     |
            ---------------------
        zJust a labelzImportant numberszRow one15zRow two300a/  
            ------------------------------------
            | Just a label | Important numbers |
            ------------------------------------
            | Row one      |                15 |
            | Row two      |               300 |
            ------------------------------------
        N)r*   rS   stripr4   )rw   datacolumn_namess      ry   test_pretty_tables(HumanFriendlyTestCase.test_pretty_tablesX  s    ##$"4(F 4 - UW	 	  (9"4(F 4 -
 UW 	  /1-dABf N G UW 	  '(;<D!Iu#56-dABf N G UW 	 r|   c                     / SQn/ SQ/ SQ/n[        [        X!5      5      [        S5      R                  5       :X  d   e/ SQn/ SQ/ SQ/n[        [        X!5      5      [        S5      R                  5       :X  d   eg)z8Test :func:`humanfriendly.tables.format_robust_table()`.r  r  r  z
            --------
            One: 1
            Two: 2
            Three: 3
            --------
            One: a
            Two: b
            Three: c
            --------
        r  r  zHere comes a
multi line column!  
            ------------------
            One: 1
            Two: 2
            Three: 3
            ------------------
            One: a
            Two: b
            Three:
            Here comes a
            multi line column!
            ------------------
        N)r4   r+   rS   r  rw   r  r  s      ry   test_robust_tables(HumanFriendlyTestCase.test_robust_tables  s    .1-dABf 
N 
G UW
 
	 
 /!OP-dABf N G UW 	 r|   c                     / SQn/ SQ/ SQ/n[        [        X!5      5      [        S5      R                  5       :X  d   e/ SQn/ SQ/ SQ/n[        [        X!5      5      [        S5      R                  5       :X  d   eg)z7Test :func:`humanfriendly.tables.format_smart_table()`.r  r  r  r  r  r  N)r4   r-   rS   r  r  s      ry   test_smart_tables'HumanFriendlyTestCase.test_smart_tables  s    .1,T@AV M F UW 	  /!OP,T@AV M F UW 	 r|   c                     / SQn/ SQ/ SQ/nU R                  [        X!5      [        S5      R                  5       5        / SQ/ SQ/nU R                  [        U5      [        S5      R                  5       5        g)z5Test :func:`humanfriendly.tables.format_rst_table()`.r  r  r  z
                ===  ===  =====
                One  Two  Three
                ===  ===  =====
                1    2    3
                a    b    c
                ===  ===  =====
            zm
                =  =  =
                1  2  3
                a  b  c
                =  =  =
            N)r   r,   rS   rstripr  s      ry   test_rst_tables%HumanFriendlyTestCase.test_rst_tables  sw     /1T0   
	
  1T"  
 	
r|   c                     [        / 5      S:X  d   e[        S/5      S:X  d   e[        SS/5      S:X  d   e[        / SQ5      S:X  d   e[        / SQSS9S	:X  d   e[        / SQS
S9S:X  d   eg)z.Test :func:`humanfriendly.text.concatenate()`.r6  rd   rf   zone and two)rd   rf   threezone, two and threeor)conjunctionzone, two or threeT)serial_commazone, two, and threeNrR   r   s    ry   test_concatenate&HumanFriendlyTestCase.test_concatenate  s    2"$$$E7#u,,,E5>*m;;;237KKKK2EI\\\\2FJ____r|   c                    SSK Jn  U R                  U" S5      / 5        U R                  U" S5      S/5        U R                  U" S5      SS/5        U R                  U" S5      / SQ5        U R                  U" S	5      / SQ5        g
)z(Test :func:`humanfriendly.text.split()`.r   )splitr6  r  zfoo, barbarzfoo, bar, bazr  r  bazzfoo,bar,bazN)humanfriendly.textr  r   )rw   r  s     ry   
test_split HumanFriendlyTestCase.test_split  st    ,rB'uw/z*UEN;/1FG}-/DEr|   c                     S Hh  u  p[        [        R                  " 5       U-
  5      nU R                  [        UR                  SS9SU-  5        U R                  [        U5      U5        Mj     [        [        R                  " 5       S-
  5      nU R                  UR                  S5        [        5       n[        R                  " S5        U R                  [        UR                  S5      S	5        [        SS
9n[        S5       H$  nU   [        R                  " S5        SSS5        M&     U R                  [        UR                  S5      S5        [        SS
9 nUc   e SSS5        g! , (       d  f       Mv  = f! , (       d  f       g= f)z!Test :func:`humanfriendly.Timer`.)
)rc   rO  )rg   	2 seconds)rC  rP  )ru  rR  )i  rS  )i   rT  )iQ rU  )i  rV  )i:	 rW  )i u rX  Tr  z%i.00g@r  rc   r   r  )	resumablerg   Nz2.00)
r   timer   r   elapsed_timestrroundedsleepnormalize_timestamprange)rw   secondstexttautomatic_timerresumable_timeritimers           ry   
test_timer HumanFriendlyTestCase.test_timer  s7   	AMG diikG+,A\!..TJGV]L]^SVT*	A $))+#$K0'

1
 	,_-I-I1MvV$/qA 

1 !  	,_-I-I1MvVT"e$$$ #"	 ! #"s   E-E?-
E<	?
Fc                    [        5       n[        SSUSS9nS H(  nUR                  US9  [        R                  " S5        M*     UR                  5         UR                  5       nUR                  " [        S5      R                  [        S5      nUR                  " [        5       Vs/ s H  oU(       d  M  UPM     nnU R                  [        U5      S	:  5        U R                  [        S
 U 5       5      5        U R                  [        S U 5       5      5        U R                  [!        [#        U5      5      [!        U5      5        gs  snf )z#Test :func:`humanfriendly.Spinner`.test spinnerr[  T)labeltotalstreaminteractive)rc   rg   r\  r[  )progressg?r6  r   c              3   ,   #    U  H
  nS U;   v   M     g7f)r	  Nr   .0lines     ry   	<genexpr>5HumanFriendlyTestCase.test_spinner.<locals>.<genexpr>  s     EutNd2u   c              3   ,   #    U  H
  nS U;   v   M     g7f)%Nr   r  s     ry   r  r    s     :EDC4KEr  N)r   rD   stepr  r  cleargetvaluereplacer3   r0   r  r/   
assertTruerq   allr   sortedset)rw   r  spinnerr  r=   r  liness          ry   test_spinner"HumanFriendlyTestCase.test_spinner  s    aTXY$HLL(L+JJsO % 	"..!126 !126 	"(,,"?H"?$4"?HE
Q'EuEEF:E::;E
+VE];	 Is   (
E6Ec                 v    [        SS9   [        R                  " S5        SSS5        g! , (       d  f       g= f)az  
Test :func:`humanfriendly.AutomaticSpinner`.

There's not a lot to test about the :class:`.AutomaticSpinner` class,
but by at least running it here we are assured that the code functions
on all supported Python versions. :class:`.AutomaticSpinner` is built
on top of the :class:`.Spinner` class so at least we also have the
tests for the :class:`.Spinner` class to back us up.
r	  )r
  rc   N)rC   r  r  r   s    ry   test_automatic_spinner,HumanFriendlyTestCase.test_automatic_spinner   s#     N3JJqM 433s   *
8c                   ^ U R                  [        5         [        / 5        SSS5        [        [        R
                  5       n[        [        SU5         Sn[        U/5      U:X  d   e SSS5        SSS5        [        [        SS 5         [        SS/5      S:X  d   e SSS5        [        [        SS 5         [        SS/5      S:X  d   e SSS5        [        [        SS	 5         [        SS/5      S:X  d   e SSS5        [        [        SS
 5         [        SS/SS9S:X  d   e SSS5        / SQm[        [        SU4S j5         [        / SQ5      S:X  d   e SSS5        SS/m[        [        SU4S j5         [        / SQ5      S:X  d   e SSS5        SS/m[        [        SU4S j5         [        / SQ5      S:X  d   e SSS5        [        [        SS 5         U R                  [        5         [        / SQ5        SSS5        SSS5        g! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GNd= f! , (       d  f       GN@= f! , (       d  f       GN= f! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       g= f)z7Test :func:`humanfriendly.prompts.prompt_for_choice()`.Nr   zonly one option (shortcut)interactive_promptc                     g)Nr  r   ps    ry   r   >HumanFriendlyTestCase.test_prompt_for_choice.<locals>.<lambda>:  s    ur|   r  r  c                     g)Nfr   r*  s    ry   r   r,  =      sr|   c                     g)Nr  r   r*  s    ry   r   r,  @  r/  r|   c                     gNr6  r   r*  s    ry   r   r,  C      rr|   default)r6  qzc                 &   > TR                  S5      $ Nr   ru   r+  repliess    ry   r   r,  G      w{{ST~r|   r  r  r  r6  c                 &   > TR                  S5      $ r9  r:  r;  s    ry   r   r,  K  r=  r|   )r  r  r  quxr?  r  r  c                 &   > TR                  S5      $ r9  r:  r;  s    ry   r   r,  O  r=  r|   c                     gr2  r   r*  s    ry   r   r,  R  r3  r|   r  )
r   r   r"   r   r   devnullrH   r   r   r    )rw   r   only_optionr<  s      @ry   test_prompt_for_choice,HumanFriendlyTestCase.test_prompt_for_choice-  sP    z*b! +
 "**!#w7:(+7;FFF 8 
 g';_M$eU^4=== N g';]K$eU^4=== L g';]K$eU^4=== L g';\J$eU^UCuLLL K !g';=UV$%:;uDDD W *g';=UV$%ABeKKK W +g';=UV$%:;uDDD W g';\J""#89!/2 : KJE +* 87 
 NM LK LK KJ WV WV WV :9 KJs   H IH2,II=I(,I:JJJ0<K+K$KK$ 
H/2
I	<I
I
I%(
I7:
J	
J
J-0
J?
K
K!	K$$
K2c                   ^^ S H2  m[        [        SU4S j5         [        S5      SL d   e SSS5        M4     S H2  m[        [        SU4S j5         [        S5      S	L d   e SSS5        M4     S
 H.  n[        [        SS 5         [        SUS9UL d   e SSS5        M0     SS/m[        [        SU4S j5         [        SS9 n[        S5      SL d   eSUR	                  5       ;   d   e SSS5        SSS5        [        [        SS 5         S H<  u  p4[        SS9 n[        SUS9SL d   eXBR	                  5       ;   d   e SSS5        M>     SSS5        [        [        SS 5         U R                  [        5         [        S5        SSS5        SSS5        g! , (       d  f       GM  = f! , (       d  f       GM  = f! , (       d  f       GMe  = f! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       M  = f! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       g= f)z=Test :func:`humanfriendly.prompts.prompt_for_confirmation()`.)r   YesYESyYr(  c                    > T$ r   r   r+  replys    ry   r   DHumanFriendlyTestCase.test_prompt_for_confirmation.<locals>.<lambda>Z      5r|   zAre you sure?TN)r0  NoNOnNc                    > T$ r   r   rL  s    ry   r   rN  ^  rO  r|   F)TFc                     gr2  r   r*  s    ry   r   rN  b  s    2r|   r4  r6  rI  c                 &   > TR                  S5      $ r9  r:  r;  s    ry   r   rN  f  r=  r|   mergedzthere's no default choicec                     g)NrI  r   r*  s    ry   r   rN  k  r/  r|   ))TzY/n)Fzy/N)Nzy/nc                     gr2  r   r*  s    ry   r   rN  q  r3  r|   )rH   r   r!   rF   get_textr   r    )rw   default_choicer   default_valueexpected_textr<  rM  s        @@ry   test_prompt_for_confirmation2HumanFriendlyTestCase.test_prompt_for_confirmationV  s    3E!'+?Q.?4GGG RQ 3 0E!'+?Q.?5HHH RQ 0 *N!'+?N.W[iiii ON * s)g';=UVd+x.?4GGG2h6G6G6IIII , W
 g';]K0\,"$/82?MZ^bbbb(,=,=,???? 0/ 1] L g';\J""#89'8 : KJ/ RQ RQ ON
 ,+ WV 0/ LK :9 KJs   F$F7
G
 
G.
'G2G.H%%G?H1H3H"H3$
F4	7
G	

G	
G+	'G..
G<?
H	H
H"
H0	,H33
Ic                 X   [        [        R                  5       n[        [        SU5         Sn[        SUS9U:X  d   eU R                  [        5         [        S5        SSS5        SSS5        SSS5        g! , (       d  f       N= f! , (       d  f       N(= f! , (       d  f       g= f)z6Test :func:`humanfriendly.prompts.prompt_for_input()`.r   zTo seek the holy grail!zWhat is your quest?r4  zWhat is your favorite color?N)r   r   rB  rH   r   r#   r   EOFError)rw   r   r]  s      ry   test_prompt_for_input+HumanFriendlyTestCase.test_prompt_for_inputu  s~    "**!#w7 9'(=}UYffff &&x0$%CD 1 8  10 87 s:   B(B
A9 B
(B9
BB


B	B
B)c                    [        [        5      u  pSU;   d   e[        [        S5      u  pSU;   d   e[        [        S5      u  pUS:w  d   e[        [        S5      u  pUR                  " 5       S:X  d   e[        R                  " SS5      n[        [        S	U-  5      u  pUR                  " 5       [        U5      :X  d   e[        R                  " SS5      n[        [        S	U-  S
5      u  pUR                  " 5       [        USS9:X  d   e[        R                  " SS5      n[        [        SU-  5      u  pUR                  " 5       [        U5      :X  d   e[        U5      S-  n[        [        SU-  5      u  pUR                  " 5       [        U5      :X  d   e[        [        SSSS9u  pUR                  " 5       [        S5      R                  5       :X  d   e[        R                  " SS5      n[        [        SU-  5      u  pUR                  " 5       [        U5      :X  d   e[        [        S5      u  p[        U5      [        S5      :X  d   e[        [        S5      u  p[        U5      [        SSS9:X  d   e[        [        S5      u  p[        U5      [        S5      :X  d   e[        [        S5      u  p[        U5      [        S5      :X  d   e[        [        S S!S"S#5      u  pUS$:X  d   e[        [        S%5      u  pUS:X  d   eUR                  " 5        Vs/ s H  n[        U5      PM     nnS&U;   d   eS'U;   d   eS(U;   d   eS)U;   d   eS*U;   d   eS+U;   d   eS,U;   d   eg-s  snf ).z Test the command line interface.zUsage:z--helpz--unsupported-optionr   z--format-number=1234567z	1,234,567r  r  z--format-size=%iz--binaryTr  z--format-length=%ig@z--format-length=%fz--format-tablez--delimiter=	z1	2	3
4	5	6
7	8	9r   z
            -------------
            | 1 | 2 | 3 |
            | 4 | 5 | 6 |
            | 7 | 8 | 9 |
            -------------
        rZ  iX  z--format-timespan=%iz--parse-size=5 KBz5 KBz--parse-size=5 YiBz5 YBz--parse-length=5 kmz5 kmz--parse-length=1.05 kmz1.05 kmz--run-commandbashz-czsleep 2 && exit 42rk   z--demozText styles:zForeground colors:zBackground colors:z!256 color mode (standard colors):z'256 color mode (high-intensity colors):z256 color mode (216 colors):z#256 color mode (gray scale colors):N)rM   r   r  r  randintr   r
   floatrS   r   intr   r   
splitlinesr4   )rw   r   r=   random_byte_count
random_lenrandom_timespanr  r!  s           ry   test_cliHumanFriendlyTestCase.test_cli  sk    %T]
6!!!$T84
6!!!$T+AB
Q$T+DE
||~,,,"NN4=$T+=@Q+QR
||~->!????"NN4=$T+=@Q+QS]^
||~->t!LLLL^^D+6
$T+?*+LM
||~z!:::::&0
$T+?*+LM
||~z!::::$T+;=MUpq
||~ ) " UW 	  !..C0$T+AO+ST
||~!AAAA$T+>?
6{j0000$T+?@
6{j====$T+@A
6{l62222$T+CD
V}Y 7777$T?FDJ^_
R %T84
Q.4.?.?.AB.AdD!.AB&&&#u,,,#u,,,2e;;;8EAAA-6664=== Cs   #M3c                    [        SS9[        < S[        < 3:X  d   e[        SS9[        < S[        < 3:X  d   e[        SS9[        < S[        < 3:X  d   e[        SS9[        < S	[        < 3:X  d   e[        SS
9[        < S[        < 3:X  d   e[        SS9[        < S[        < 3:X  d   e[        SS9[        < S[        < 3:X  d   e[        SS9[        < S[        < 3:X  d   e[        SSS9[        < S[        < 3:X  d   e[        SS9[        < S[        < 3:X  d   e[        SS9[        < S[        < 3:X  d   e[        SS9[        < S[        < 3:X  d   e[        SS9[        < S[        < 3:X  d   e[        SS9[        < S[        < 3:X  d   eU R                  [        5         [        SS9  SSS5        g! , (       d  f       g= f) z1Test :func:`humanfriendly.terminal.ansi_style()`.Tboldr+  )faintr  )italicr  )	underline4)inverse7)strike_through9bluecolor34)
background44)r}  bright94   z38;5;214z39;5;214)r   r   r   z
38;2;0;0;0)   r  r  z38;2;255;255;255)2   d      z48;2;50;100;150unknownN)r5   r.   r2   r   r   r   s    ry   test_ansi_style%HumanFriendlyTestCase.test_ansi_style  sy   t$8X(FFFF%Hh)GGGG&Xx*HHHHD)(-KKKK$'h+IIII.Xx2PPPP'x+JJJJV,Hh0OOOOt4Hh8WWWW$(H(MMMMS)x-RRRR	*(H.UUUU0hX`4aaaa^4QY[c8ddddz*Y' +**s   ;
G
Gc                     Sn[        U5      [        U5      :X  d   e[        USS9nX!:w  d   e[        U5      [        U5      :  d   e[        U5      [        U5      :X  d   eg)z1Test :func:`humanfriendly.terminal.ansi_width()`.WhateverTrq  N)rq   r6   r7   )rw   r   wrappeds      ry   test_ansi_width%HumanFriendlyTestCase.test_ansi_width  sa    4yJt,,,,Dt,7|c$i'''4yJw////r|   c                     SnU[        U5      :X  d   e[        USS9R                  [        5      (       d   e[        USS9R                  [        5      (       d   eg)z0Test :func:`humanfriendly.terminal.ansi_wrap()`.r  Trq  N)r7   
startswithr.   endswithr1   rw   r   s     ry   test_ansi_wrap$HumanFriendlyTestCase.test_ansi_wrap  sU    y&&&D)44X>>>>D)22:>>>>r|   c                    [        S5      S:X  d   e[        S5      S:X  d   e[        S5      S:X  d   e[        S5      S:X  d   e[        S5      S:X  d   e[        S	5      S
:X  d   e[        S5      S
:X  d   e[        S5      S:X  d   e[        S5      S:X  d   e[        S5      S:X  d   e[        S5      S:X  d   e[        S5      S:X  d   e[        S5      S:X  d   e[        S5      S:X  d   e[        S5      S:X  d   e[        S5      S:X  d   e[        S5      S:X  d   e[        S5      S:X  d   e[        S5      S :X  d   e[        S!5      S:X  d   eS" nS#[        S$US%9;  d   eS#[        S&US%9;   d   e[        S'5      (       d   eg())z@Test the :func:`humanfriendly.terminal.html_to_ansi()` function.zJust some plain textz+<a href="https://python.org">python.org</a>z=[0m[4;94mpython.org[0m ([0m[4;94mhttps://python.org[0m)z@<a href="mailto:peter@peterodding.com">peter@peterodding.com</a>z$[0m[4;94mpeter@peterodding.com[0mzLet's try <b>bold</b>zLet's try [0m[1mbold[0mz5Let's try <span style="font-weight: bold">bold</span>zLet's try <i>italic</i>zLet's try [0m[3mitalic[0mz8Let's try <span style="font-style: italic">italic</span>zLet's try <ins>underline</ins>zLet's try [0m[4munderline[0mzCLet's try <span style="text-decoration: underline">underline</span>zLet's try <s>strike-through</s>z$Let's try [0m[9mstrike-through[0mzKLet's try <span style="text-decoration: line-through">strike-through</span>z$Let's try <code>pre-formatted</code>z$Let's try [0m[33mpre-formatted[0mz6Let's try <span style="color: #AABBCC">text colors</s>z0Let's try [0m[38;2;170;187;204mtext colors[0mzOLet's try <span style="background-color: rgb(50, 50, 50)">background colors</s>z3Let's try [0m[48;2;50;50;50mbackground colors[0mz Let's try some<br>line<br>breakszLet's try some
line
breaksz&#38;&z&amp;z&gt;>z&lt;<z&#x26;c                 &    U R                  SS5      $ )N:wink:z;-))r  )r   s    ry   callback9HumanFriendlyTestCase.test_html_to_ansi.<locals>.callback'  s    <<%00r|   r  z<b>:wink:</b>)r  z<code>:wink:</code>a  
            Tweakers zit er idd nog steeds:<br><br>
            peter@peter-work&gt; curl -s <a href="tweakers.net">tweakers.net</a> | grep -i hosting<br>
            &lt;a href="<a href="http://www.true.nl/webhosting/">http://www.true.nl/webhosting/</a>"
                rel="external" id="true" title="Hosting door True"&gt;&lt;/a&gt;<br>
            Hosting door &lt;a href="<a href="http://www.true.nl/vps/">http://www.true.nl/vps/</a>"
                title="VPS hosting" rel="external"&gt;True</a>
        NrA   )rw   r  s     ry   test_html_to_ansi'HumanFriendlyTestCase.test_html_to_ansi  sW   237MMMMIJ]^ 	^ ^ ^_;< 	< < 348]]]]UV12 	2 2 5634 	4 4XY34 	4 4 <=67 	7 7cd67 	7 7 =>;< 	< <kl;< 	< < BC;< 	< < VWGH 	H H opJK 	K K >?*+ 	+ + G$+++G$+++F#s***F#s***H%,,,	1 |OhOOOO<(=QQQQ     	 r|   c                    Sn[        SS9 n[        U5        U R                  U/UR                  R	                  5       5        U R                  / UR
                  R	                  5       5        SSS5        g! , (       d  f       g= f)z:Test the :func:`humanfriendly.terminal.output()` function.z%Standard output generated by output()FrW  N)rF   r=   r   r   r   r   rw   r   r   s      ry   test_generate_output*HumanFriendlyTestCase.test_generate_output9  s`    6%(H4LdVX__%>%>%@AR!:!:!<= )((   A!A66
Bc                    Sn[        SS9 n[        U5        U R                  / UR                  R	                  5       5        U R                  U/UR
                  R	                  5       5        SSS5        g! , (       d  f       g= f)z;Test the :func:`humanfriendly.terminal.message()` function.z%Standard error generated by message()FrW  N)rF   r<   r   r   r   r   r  s      ry   test_generate_message+HumanFriendlyTestCase.test_generate_messageA  s`    6%(HDMR!:!:!<=dVX__%>%>%@A )((r  c                 &   SSK Jn  SnU" SS9 n[        U5        U R                  / UR                  R                  5       5        U R                  [        USS9/U R                  UR                  5      5        SSS5        g! , (       d  f       g= f)	z;Test the :func:`humanfriendly.terminal.warning()` function.r   rF   z%Standard error generated by warning()FrW  redr|  N)	r   rF   r@   r   r   r   r7   ignore_coverage_warningr   )rw   rF   r   r   s       ry   test_generate_warning+HumanFriendlyTestCase.test_generate_warningI  sp    *6%(HDMR!:!:!<=iE:;T=Y=YZbZiZi=jk )((s   A*B
Bc                 ^    UR                  5        Vs/ s H  nSU;  d  M  UPM     sn$ s  snf )z
Filter out coverage.py warning from standard error.

This is intended to remove the following line from the lines captured
on the standard error stream:

Coverage.py warning: No data was collected. (no-data-collected)
zno-data-collected)r   )rw   r  r  s      ry   r  -HumanFriendlyTestCase.ignore_coverage_warningR  s0     "(!1!1!3W!37JRV7V!3WWWs   
**c                     [        S5      S/:X  d   e[        S5      SS/:X  d   e[        S5      SS/:X  d   e[        S5      S/:X  d   e[        S5      S/:X  d   e[        S	5      / S
Q:X  d   eg)z<Test :func:`humanfriendly.terminal.clean_terminal_output()`.r  r  r  zfoobar
bazr  zaaaababazaaabzfoo
bar
baz


r  N)r8   r   s    ry   test_clean_output'HumanFriendlyTestCase.test_clean_output]  s     %U+w666$Z0UENBBB$_5%GGG$Y/E7:::$Z0UG;;;$%:;?TTTTr|   c                    [        5       u  pUS:  d   eUS:  d   e[        R                  n[        R                  n[        R                  n [        5       [        l        [        5       [        l        [        5       [        l        [        5       u  pUS:  d   eUS:  d   e[        R                  S   n S[        R                  S'   [        5       u  pUS:  d   eUS:  d   e U[        R                  S'    U[        l        U[        l        U[        l        g! U[        R                  S'   f = f! U[        l        U[        l        U[        l        f = f)z9Test :func:`humanfriendly.terminal.find_terminal_size()`.r   PATHr6  N)r:   r   r   r   r   r   r   r  )rw   r!  columnssaved_stdinsaved_stdoutsaved_stderr
saved_paths          ry   test_find_terminal_size-HumanFriendlyTestCase.test_find_terminal_sizel  s   +- qyy{{
 iizzzz	& 
CI!CJ!CJ 01NE199Q;; F+J0%'

6"!3!5qy y{"{%/

6"#CI%CJ%CJ	 &0

6"#CI%CJ%CJs%   A(D5 7/D 'D5 D22D5 5#Ec                    SSK Jn  [        [        4 H  n[        R
                  [        R                  4 H#  nU" 5          U" U5      (       d   e SSS5        M%     [        [        R                  5       nU" U5      (       a   e SSS5        U" [        5       5      (       d  M   e   g! , (       d  f       M  = f! , (       d  f       N<= f)z8Test the functions that check for terminal capabilities.r   r  N)r   rF   r9   r?   r   r   r   r   r   rB  r   )rw   rF   test_streamr  r   s        ry   test_terminal_capabilities0HumanFriendlyTestCase.test_terminal_capabilities  s    *02JJK
 **cjj0"_&v.... %_ 1 bjj!V&v..... " #68,,,, K %_ "!s    B+6B=+
B:=
C	c                    [         R                  R                  SS5      n S[         R                  S'   SR                  S [	        S5       5       5      n[        5        n[        U5        X#R                  5       ;   d   e SSS5        Ub  U[         R                  S'   g[         R                  R                  S5        g! , (       d  f       NE= f! Ub  U[         R                  S'   f [         R                  R                  S5        f = f)z1Test :func:`humanfriendly.terminal.show_pager()`.PAGERNcatr   c              3   8   #    U  H  n[        S 5      v   M     g7f)   N)rV   )r  r  s     ry   r  8HumanFriendlyTestCase.test_show_pager.<locals>.<genexpr>  s     #Iy!M"$5$5ys   r  )	r   r  rt   r   r  rF   r>   r[  ru   )rw   original_pagerrandom_textr   s       ry   test_show_pager%HumanFriendlyTestCase.test_show_pager  s    6	( #(BJJw ))#IuRy#IIKH;'"&7&7&9999 ! )&4

7# 

w' ! )&4

7# 

w's#   >C  !CC 
CC 8D
c                 R  ^ S[        S5      ;  d   eS[        [        SSS95      ;   d   eSS/nS H  n[        R                  R	                  SS	5      n U[        R                  S'   [        5       mUS
:X  a  [        U4S jU 5       5      (       d   eO[        U4S jU 5       5      (       a   eUb  U[        R                  S'   M  [        R                  R                  S5        M     g	! Ub  U[        R                  S'   f [        R                  R                  S5        f = f)z8Test :func:`humanfriendly.terminal.get_pager_command()`.z--RAW-CONTROL-CHARSzUsage messageTrq  z	--no-initz--quit-if-one-screen)r  lessr  Nr  c              3   ,   >#    U  H	  oT;   v   M     g 7fr   r   r  optcommand_lines     ry   r  ?HumanFriendlyTestCase.test_get_pager_command.<locals>.<genexpr>  s     W>Vsl2>V   c              3   ,   >#    U  H	  oT;   v   M     g 7fr   r   r  s     ry   r  r    s     "[BZ3,#6BZr  )r;   r7   r   r  rt   r  anyru   )rw   options_specific_to_lesspagerr  r  s       @ry   test_get_pager_command,HumanFriendlyTestCase.test_get_pager_command  s    %,=o,NNNN$(9)OZ^:_(````$/1G#H "EZZ^^GT:N,&+

7#02F?W>VWWWWW""[BZ"[[[[[!-*8BJJw' JJNN7+% # "-*8BJJw' JJNN7+s   AC..8D&c                 N    [        [        S5      5      [        / SQ5      :X  d   eg)z7Test :func:`humanfriendly.usage.find_meta_variables()`.z
            Here's one example: --format-number=VALUE
            Here's another example: --format-size=BYTES
            A final example: --format-timespan=SECONDS
            This line doesn't contain a META variable.
        )VALUEBYTESSECONDSN)r  rX   r   s    ry   test_find_meta_variables.HumanFriendlyTestCase.test_find_meta_variables  s1    ) +  
 567 	7 7r|   c                 z    U R                  S5      u  pSU;   d   eSU;   d   eSU;   d   eSU;   d   eSU;   d   eg)z?Test :func:`humanfriendly.usage.parse_usage()` (a simple case).z
            Usage: my-fancy-app [OPTIONS]

            Boring description.

            Supported options:

              -h, --help

                Show this message and exit.
        Usage: my-fancy-app [OPTIONS]zBoring description.Supported options:z
-h, --helpzShow this message and exit.Npreprocess_parse_resultrw   introductionoptionss      ry   test_parse_usage_simple-HumanFriendlyTestCase.test_parse_usage_simple  sb     $ < < 
> 
! /,>>>$444#|333w&&&,777r|   c                     U R                  S5      u  pSU;   d   e[        S U 5       5      (       d   eSU;   d   eSU;   d   eSU;   d   eSU;   d   eSU;   d   eg	)
z?Test :func:`humanfriendly.usage.parse_usage()` (a tricky case).a<  
            Usage: my-fancy-app [OPTIONS]

            Here's the introduction to my-fancy-app. Some of the lines in the
            introduction start with a command line option just to confuse the
            parsing algorithm :-)

            For example
            --an-awesome-option
            is still part of the introduction.

            Supported options:

              -a, --an-awesome-option

                Explanation why this is an awesome option.

              -b, --a-boring-option

                Explanation why this is a boring option.
        r  c              3   ,   #    U  H
  nS U;   v   M     g7f)zstill part of the introductionNr   )r  r+  s     ry   r  @HumanFriendlyTestCase.test_parse_usage_tricky.<locals>.<genexpr>  s     O,Q3q8,r  r  z-a, --an-awesome-optionz*Explanation why this is an awesome option.z-b, --a-boring-optionz(Explanation why this is a boring option.N)r  r  r  s      ry   test_parse_usage_tricky-HumanFriendlyTestCase.test_parse_usage_tricky  s     $ < < > !, /,>>>O,OOOOO#|333(G333;wFFF&'1119WDDDr|   c                     U R                  S5      u  pSU;   d   eSU;   d   eSU;   d   eSU;   d   eSU;   d   eSU;   d   eSU;   d   eg	)
zWTest :func:`humanfriendly.usage.parse_usage()` against option labels containing commas.a<  
            Usage: my-fancy-app [OPTIONS]

            Some introduction goes here.

            Supported options:

              -f, --first-option

                Explanation of first option.

              -s, --second-option=WITH,COMMA

                This should be a separate option's description.
        r  zSome introduction goes here.r  z-f, --first-optionzExplanation of first option.z-s, --second-option=WITH,COMMAz/This should be a separate option's description.Nr  r  s      ry   test_parse_usage_commas-HumanFriendlyTestCase.test_parse_usage_commas  s~     $ < < > !  /,>>>-===#|333#w...-888/7:::@GKKKr|   c                 J    [        S [        [        U5      5       5       5      $ )z:Ignore leading/trailing whitespace in usage parsing tests.c              3   j   #    U  H$  o Vs/ s H  o"R                  5       PM     snv   M&     g s  snf 7fr   )r  )r  rr+  s      ry   r  @HumanFriendlyTestCase.preprocess_parse_result.<locals>.<genexpr>5  s(     O5N+Aggi+5N+s   	3.3)tuplerZ   rS   r  s     ry   r  -HumanFriendlyTestCase.preprocess_parse_result3  s    O[5NOOOr|   c                    Sn[        U5      n[        U5      [        U5      :  d   eUR                  S5      (       d   eSn[        U5      n[        U5      [        U5      :  d   eX;   d   eUR                  U5      (       a   eSn[        U5      nUR                  5       n[        US   ;   d   e[        US   ;  d   eg)z0Test :func:`humanfriendly.usage.format_usage()`.zJust one --optionz	Just one zUsage: humanfriendly [OPTIONS]z^--valid-option=VALID_METAVAR
VALID_METAVAR is bogus
INVALID_METAVAR should not be highlighted
rc   rg   N)rY   rq   r  rj  r.   )rw   
usage_textformatted_textformatted_liness       ry   test_format_usage'HumanFriendlyTestCase.test_format_usage7  s     )
%j1>"S_444((55555
%j1>"S_444+++!,,Z8888: 	
 &j1(335?1----q1111r|   c                     [        S5      S:X  d   e[        S5      S:X  d   eS[        [        S5      5      ;   d   e[        S S 5       5      (       d   eg	)
z0Test :func:`humanfriendly.usage.render_usage()`.zUsage: some-command WITH ARGSz#**Usage:** `some-command WITH ARGS`r  z**Supported options:**z
code-blockz_
            Here comes a shell command:

              $ echo test
              test
        c              3   P   #    U  H  nU[        [        S 5      5      ;   v   M     g7f)zm
            Supported options:

              -n, --dry-run

                Don't change anything.
        N)r[   rS   )r  tokens     ry   r  :HumanFriendlyTestCase.test_render_usage.<locals>.<genexpr>[  s3      4 3% L 1 *   3s   $&)z`-n`z`--dry-run`N)r[   rS   r  r   s    ry   test_render_usage'HumanFriendlyTestCase.test_render_usageQ  sy    ;<@eeee015MMMM|F 4 -    	   4 34 4 4 	4 4r|   c                 H   [        SS5      S 5       n[        5       n[        [        SU5         U" SS5      S:X  d   eU R	                  [
        5         U" SSS5        SSS5        SSS5        UR                  (       d   eg! , (       d  f       N*= f! , (       d  f       N3= f)z.Test the deprecated_args() decorator function.r  r  c                  H    U S   S:X  d   eU R                  S5      S;   d   eg)Nr  r  )Nr  rk   )rt   )r  s    ry   test_functionAHumanFriendlyTestCase.test_deprecated_args.<locals>.test_functione  s.    5>U***;;u%666r|   warnrk   r  N)r   r\   rH   warningsr   	TypeErrorr   )rw   r  fake_fns      ry   test_deprecated_args*HumanFriendlyTestCase.test_deprecated_argsc  s    		&	 
'	 +h8 ."444""9-eUE2 . 9 !!!! .- 98s#   %BBB
B	B
B!c                    [        5       n[        [        SU5         [        R                  [
           n[        SS9n[        X#5      nUR                  [        :X  d   e SSS5        UR                  (       d   eg! , (       d  f       N"= f)@Test that the DeprecationProxy class emits deprecation warnings.r  humanfriendly.text.concatenater  N)
r\   rH   r  r   modulesr   rr   r   rR   r   )rw   r
  modulealiasesproxys        ry   $test_alias_proxy_deprecation_warning:HumanFriendlyTestCase.test_alias_proxy_deprecation_warningq  sk    +h8[[*F'GHG$V5E$$333	 9
 !!!! 98s   AA;;
B	c                 *   [        [        R                  S[        R                  " S5      5         [        [        SS9  S[        [        R                  [           5      ;   d   eS[        [        5      ;   d   e SSS5        g! , (       d  f       g= f)r  sphinxr  r  rR   N)	rI   r   r  types
ModuleTyper   r   dirr   r   s    ry   $test_alias_proxy_sphinx_compensation:HumanFriendlyTestCase.test_alias_proxy_sphinx_compensation{  sd    h0@0@0JK81QR CH(=$>>>> K$9999 LKKs   A
B
Bc           	          [         R                  [           n[        [        SS9  UR                  R                  5       n[        SSSUSUS9  SR                  U5      UR                  :w  d   eg)z?Test that aliases can be injected into generated documentation.r  r  Nappwhatr   rx   r  r!  r   )r   r  r   r   __doc__rj  r$   r   )rw   r  r!  s      ry   #test_alias_proxy_sphinx_integration9HumanFriendlyTestCase.test_alias_proxy_sphinx_integration  s\    X&x-MN))+!dDfVZbghyy6>>111r|   c           	      h    " S S[         5      nU" 5       n[        U5        [        UR                  S   :X  d   e[        UR                  S   :X  d   e[
        UR                  S   ;   d   e[        UR                  S   ;   d   e[        UR                  S   ;   d   e[        SSSUR                  SSS	9S
L d   e[        SSSUR                  SSS	9SL d   eSSKJnJn  U R                  U5      (       d   eU R                  U5      (       a   eU R                  UR                  5      (       a   eg)z,Test the :mod:`humanfriendly.sphinx` module.c                   8    \ rS rSrS rS rS rS rS rS r	Sr
g	)
AHumanFriendlyTestCase.test_sphinx_customizations.<locals>.FakeAppi  c                      0 U l         0 U l        g r   	callbacksrolesr   s    ry   __init__JHumanFriendlyTestCase.test_sphinx_customizations.<locals>.FakeApp.__init__  s    !#
r|   c                     g)z%Documented unofficial special method.Nr   r   s    ry   __documented_special_method___HumanFriendlyTestCase.test_sphinx_customizations.<locals>.FakeApp.__documented_special_method__      r|   c                     g r   r   r   s    ry   __undocumented_special_method__aHumanFriendlyTestCase.test_sphinx_customizations.<locals>.FakeApp.__undocumented_special_method__  r0  r|   c                      X R                   U'   g r   )r*  )rw   r   r  s      ry   add_roleJHumanFriendlyTestCase.test_sphinx_customizations.<locals>.FakeApp.add_role  s    #+

4 r|   c                 Z    U R                   R                  U/ 5      R                  U5        g r   )r)  rv   append)rw   eventr  s      ry   connectIHumanFriendlyTestCase.test_sphinx_customizations.<locals>.FakeApp.connect  s!    ))%4;;HEr|   c                     g)z.Usage: This is not supposed to be reformatted!Nr   r   s    ry   bogus_usageMHumanFriendlyTestCase.test_sphinx_customizations.<locals>.FakeApp.bogus_usage  r0  r|   r(  N)r   r   r   r   r+  r.  r2  r5  r:  r=  r   r   r|   ry   FakeAppr&    s!     ,Fr|   r?  manpypizautodoc-process-docstringzautodoc-skip-memberNT)r  r   r   rx   skipr  Fr   )clir  )r   r'   r%   r*  r&   r$   r)  r(   r)   r.  r2  humanfriendlyrC  r  docstring_is_reformattedr=  )rw   r?  fake_apprC  r  s        ry   test_sphinx_customizations0HumanFriendlyTestCase.test_sphinx_customizations  sW   	f 	2 9h8>>%0000HNN62222(H,>,>?Z,[[[['8+=+=>S+TTTT%););<W)XXXX'4d55t
 	 	  (4d77t
 	 	  	. ,,S1111 008888 001E1EFFFFFr|   c           	          [        UR                  5      R                  5       n[        U5      n[	        SSSUSUS9  X#:g  $ )zOCheck whether :func:`.usage_message_callback()` reformats a module's docstring.Nr  )rW   r!  rj  listr)   )rw   entityr!  saved_liness       ry   rE  .HumanFriendlyTestCase.docstring_is_reformatted  sC     0;;=5k4dE	
 ##r|   r   N)Or   r   r   r   r!  rz   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r$  r3  r@  rk  rz  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r"  r%  rD  r_  rc  rn  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r"  rG  rE  r   r   r|   ry   r^   r^      s   7()T
!F;-$, /$-,	++)
(
2CG=9
,09d!6%A00	7 <BDC&P>8
8	`F"%H<"'3R9>
EG>R(&0?BH>Bl	XU(&T-"(,,878*EBL6P244$"":28Gt$r|   r^   c                 .    S[        [        U 5      US9-  $ )z
Round timestamps to the given number of digits.

This helps to make the test suite less sensitive to timing issues caused by
multitasking, processor scheduling, etc.
z%.2f)ndigits)roundrh  )r2  rO  s     ry   r  r    s     E%,888r|   )rc   )vr!  rb  r`  r   r  r9  r   r   r  r  r   r  rD  r   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   humanfriendly.caser   r   humanfriendly.clir   humanfriendly.compatr   humanfriendly.decoratorsr   humanfriendly.deprecationr   r   r   r   humanfriendly.promptsr    r!   r"   r#   humanfriendly.sphinxr$   r%   r&   r'   r(   r)   humanfriendly.tablesr*   r+   r,   r-   humanfriendly.terminalr.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   humanfriendly.terminal.htmlrB   humanfriendly.terminal.spinnersrC   rD   humanfriendly.testingrE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   r  rP   rQ   rR   rS   rT   rU   rV   rW   humanfriendly.usagerX   rY   rZ   r[   mockr\   r^   r  r   r|   ry   <module>r_     s    2   	  	  
         * G " ) + d d        * 5 E   	 	 	  L$H L$^*9r|   