
    Ng7                    f   d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ ddl m!Z!m"Z" ddl#m$Z$ ddl%m&Z& ddl'm(Z( ddl)m*Z*m+Z+m,Z,m-Z- dd	l.m/Z/m0Z0m1Z1m2Z2 dd
l3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9 ddl:m;Z;m<Z<m=Z=m>Z> ddl?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZR ddlSmTZT ddlUmVZVmWZW ddlXmYZYmZZZm[Z[m\Z\m]Z]m^Z^m_Z_m`Z`maZambZbmcZc ddldmeZemfZfmgZgmhZhmiZimjZjmkZkmlZl ddlmmnZnmoZompZpmqZq ddlrmsZs  G d de_          ZtddZudS )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                      e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d  Z"d! Z#d" Z$d# Z%d$ Z&d% Z'd& Z(d' Z)d( Z*d) Z+d* Z,d+ Z-d, Z.d- Z/d. Z0d/ Z1d0 Z2d1 Z3d2 Z4d3 Z5d4 Z6d5 Z7d6 Z8d7 Z9d8 Z:d9 Z;d: Z<d; Z=d< Z>d= Z?d> Z@d? ZAd@ ZBdA ZCdB ZDdC ZEdD ZFdE ZGdF ZHdG ZIdH ZJdI ZKdJ ZLdKS )LHumanFriendlyTestCasez-Container for the `humanfriendly` test suite.c                 x   t          t          ddg                    dk    sJ t          t          ddgdd                    d	k    sJ t          t          t          dd
                              dk    sJ t          t          t          dd          dd                    d	k    sJ t          t          ddd                    d	k    sJ t          j        g d          }t          |          d	k    sJ t          d          }|                    d          dk    sJ t          d          }|                    d          dk    sJ t          |          dk    sJ t          d          }|                    d          dk    sJ |                    dd           |d         dk    sJ t          d          }d|v sJ t          d          }|d= t          |          dk    sJ t          d          }|d         dk    sJ t          d          }d|d<   |d         dk    sJ dS )z#Test the CaseInsensitiveDict class.)keyT)KEYF   )oneT)ONEFFT)rc   two   )r`   ra   )rc   rd   )rc   rd   re   )Onerc   rd   Twore   TWO*   )existing_keyExisting_Keyr   	other_key   	Other_Keyrk   N)lenr   dictfromkeysgetpop
setdefault)selfobjs     O/var/www/html/ai-engine/env/lib/python3.11/site-packages/humanfriendly/tests.pytest_case_insensitive_dictz0HumanFriendlyTestCase.test_case_insensitive_dict   s    &~'FGGHHAMMMM&~'FEW[\\\]]abbbbb&t%'@'@'@AABBaGGGG&t%'@'@'@eQUVVVWW[\\\\\&4UEEEFF!KKKK!*+U+U+UVV3xx1}}}}!r222ww~&&",,,,!r222ww~&&",,,,3xx1}}}}!r222~~n--3333{B''';2%%%%!r222$$$$!r2223xx1}}}}!r222>"b((((!r222 N>"b((((((    c                     t          d          }t          d          }||k    sJ i }d||<   d||<   t          |          dk    sJ dS )z"Test the CaseInsensitiveKey class.zPlease don't shoutzPLEASE DON'T SHOUTrb   rf   N)r   rp   )rv   politerudemappings       rx   test_case_insensitive_keyz/HumanFriendlyTestCase.test_case_insensitive_key   sa     $$899!"677~~~~7||q      rz   c                 R   t                      5 }t          j                            d           t          j                            d           |j                                        dgk    sJ |j                                        dgk    sJ 	 ddd           dS # 1 swxY w Y   dS )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)rv   capturers     rx   test_capture_outputz)HumanFriendlyTestCase.test_capture_output   s    __ 	FJ6777J0111?,,..3J2KKKKK?,,..3D2EEEEEE		F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	Fs   A?BB #B c                     d }t          t                    } ||          }|                     t          |           |                     t          j        |           dS )z#Test the skip_on_raise() decorator.c                      t                      N)NotImplementedError rz   rx   test_fnz9HumanFriendlyTestCase.test_skip_on_raise.<locals>.test_fn   s    %'''rz   N)rN   r   assertRaisesunittestSkipTest)rv   r   decorator_fndecorated_fns       rx   test_skip_on_raisez(HumanFriendlyTestCase.test_skip_on_raise   sd    	( 	( 	($%899#|G,,-w777(+\:::::rz   c                     fdt                    dk    sJ d }|                     t                    5  t          |d           ddd           dS # 1 swxY w Y   dS )zFTest :func:`~humanfriendly.testing.retry()` based on assertion errors.c                  N    t           d          st           dd           J dS )N
was_calledTFyeshasattrsetattrsuccess_helpers   rx   r   z>HumanFriendlyTestCase.test_retry_raise.<locals>.success_helper   s1    ><88 d;;;urz   r   c                      J r   r   r   rz   rx   failure_helperz>HumanFriendlyTestCase.test_retry_raise.<locals>.failure_helper   s    Lrz   rb   timeoutN)rL   r   AssertionError)rv   r   r   s     @rx   test_retry_raisez&HumanFriendlyTestCase.test_retry_raise   s    	 	 	 	 	 ^$$----	 	 	~.. 	- 	-.!,,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-s   AAAc                     fdt                    dk    sJ |                     t                    5  t          d d           ddd           dS # 1 swxY w Y   dS )zCTest :func:`~humanfriendly.testing.retry()` based on return values.c                  N    t           d          st           dd           dS dS )Nr   TFrj   r   r   s   rx   r   z?HumanFriendlyTestCase.test_retry_return.<locals>.success_helper   s3    ><88 d;;;u rrz   rj   c                      dS )NFr   r   rz   rx   <lambda>z9HumanFriendlyTestCase.test_retry_return.<locals>.<lambda>   s    % rz   rb   r   N)rL   r   rE   )rv   r   s    @rx   test_retry_returnz'HumanFriendlyTestCase.test_retry_return   s    	 	 	 	 	 ^$$****/00 	, 	,--++++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,s   AAAc                 0   t                      }t          d          }t          |d|          5 }t          j                            |          sJ t          j                            t          j                            ||                    sJ t          j	        |t          j
        t          j
        t          j
                  }|                    d          \  }}|j        dk    sJ |dk    sJ |dk    sJ 	 d	d	d	           d	S # 1 swxY w Y   d	S )
z2Test :class:`humanfriendly.testing.MockedProgram`.z
            # This goes to stdout.
            tr a-z A-Z
            # This goes to stderr.
            echo Fake warning >&2
        rj   )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   )rv   r   r   	directoryprogramr   r   s          rx   test_mocked_programz)HumanFriendlyTestCase.test_mocked_program   sR       FCCC 	/y7==+++++7>>"',,y$"?"?@@@@@ &t:?:?cmcrsssG$007G0HHNFF%++++-----......	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/s   CDDDc                    t                      5 }t          j                            |          sJ t          j                            |d          }t          |d          5 }|                    d           ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   t          j                            |          rJ t          j                            |          rJ dS )z7Test :class:`humanfriendly.testing.TemporaryDirectory`.z	some-filewzHello world!N)rJ   r   r   r   r   openr   exists)rv   r   temporary_filehandles       rx   test_temporary_directoryz.HumanFriendlyTestCase.test_temporary_directory   s?   !! 	-Y7==+++++W\\)[AANnc** -f^,,,- - - - - - - - - - - - - - -	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-
 7>>.111117>>),,,,,,,s6   AB!B7BB	B
B	BB!Bc                 d   t                      5 }t          j                            |t	                                }t          j                            |          rJ t          |           t          j                            |          sJ t          j                            |t	                      t	                                }t          j                            |          rJ t          |           t          j                            |          sJ 	 ddd           dS # 1 swxY w Y   dS )z+Test :func:`humanfriendly.testing.touch()`.N)rJ   r   r   r   rV   r   rO   )rv   r   filenames      rx   
test_touchz HumanFriendlyTestCase.test_touch
  s(   !! 
	,Yw||I}??Hw~~h/////(OOO7>>(+++++w||I}PPHw~~h/////(OOO7>>(++++++
	, 
	, 
	, 
	, 
	, 
	, 
	, 
	, 
	, 
	, 
	, 
	, 
	, 
	, 
	, 
	, 
	, 
	,s   DD%%D),D)c                      G d dt                     } |            }|j        dk    sJ t          |dd          5 }||u sJ |j        dk    sJ 	 ddd           n# 1 swxY w Y   |j        dk    sJ dS )z5Test :class:`humanfriendly.testing.PatchedAttribute`.c                       e Zd ZdZdS );HumanFriendlyTestCase.test_patch_attribute.<locals>.Subjectrj   N)__name__
__module____qualname__my_attributer   rz   rx   Subjectr     s        LLLrz   r   rj   r      N)objectr   rH   )rv   r   instancereturn_values       rx   test_patch_attributez*HumanFriendlyTestCase.test_patch_attribute  s    	 	 	 	 	f 	 	 	799$****h;; 	/|8++++(B.....	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ $******s   AA!$A!c                     t          d          }|d         du sJ t          |dd          5 }||u sJ |d         du sJ 	 ddd           n# 1 swxY w Y   |d         du sJ dS )z0Test :class:`humanfriendly.testing.PatchedItem`.T)my_itemr   FN)rq   rI   )rv   r   r   s      rx   test_patch_itemz%HumanFriendlyTestCase.test_patch_item#  s    %%%	"d****9e44 	08++++I&%/////	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	"d******s   AAAc                 X    t          d           \  }}|                     |d           dS )z*Test that run_cli() intercepts SystemExit.c                  *    t          j        d          S )Nrj   )r   exitr   rz   rx   r   zDHumanFriendlyTestCase.test_run_cli_intercepts_exit.<locals>.<lambda>.  s    SXb\\ rz   rj   N)rM   assertEqualrv   r   r=   s      rx   test_run_cli_intercepts_exitz2HumanFriendlyTestCase.test_run_cli_intercepts_exit,  s4    $%9%9::
FR(((((rz   c                 `    t          | j                  \  }}|                     |d           dS )z*Test that run_cli() intercepts exceptions.rb   N)rM   run_cli_raise_otherr   r   s      rx   test_run_cli_intercepts_errorz3HumanFriendlyTestCase.test_run_cli_intercepts_error1  s3    $T%=>>
FQ'''''rz   c                     t                      )z*run_cli() sample that raises an exception.)
ValueErrorrv   s    rx   r   z)HumanFriendlyTestCase.run_cli_raise_other6  s    llrz   c                     t                      dz   t          fd          \  }}|                     |d           |                     |           dS )z&Test that run_cli() intercepts output.
c                  B    t           j                                       S r   )r   r   r   )expected_outputs   rx   r   zFHumanFriendlyTestCase.test_run_cli_intercepts_output.<locals>.<lambda>=  s    SZ-=-=o-N-N rz   r   N)rV   rM   r   )rv   r   r=   r   s      @rx   test_run_cli_intercepts_outputz4HumanFriendlyTestCase.test_run_cli_intercepts_output:  s_    '//D0$%N%N%N%NOO
FQ'''11111rz   c                     t          d           }t          d           } |             |            k    sJ  |             |            k    sJ  |             |            k    sJ dS )zTest the caching decorator.c                  (    t          j                     S r   randomr   rz   rx   r   z>HumanFriendlyTestCase.test_caching_decorator.<locals>.<lambda>D      6=?? rz   c                  (    t          j                     S r   r   r   rz   rx   r   z>HumanFriendlyTestCase.test_caching_decorator.<locals>.<lambda>E  r   rz   Nr   )rv   abs      rx   test_caching_decoratorz,HumanFriendlyTestCase.test_caching_decoratorA  su     **++**++qssaacczzzzqssaacczzzzqssaacczzzzzzrz   c                     t          d          dk    sJ t          dd          dk    sJ t          dd          d	k    sJ d
S )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    rx   test_compactz"HumanFriendlyTestCase.test_compactK  s    |$$----  45 5 5 5    !BC C C C C Crz   c                 ,   t          d          dk    sJ t          d          dk    sJ t          d          dk    sJ t          d          dk    sJ t          d          dk    sJ t          d          dk    sJ t          d          dk    sJ dS )	z6Test :func:`humanfriendly.text.compact_empty_lines()`.fooz	foofoo
barzfoo

barz	foo


barz
foo



barzfoo




barN)rQ   r   s    rx   test_compact_empty_linesz.HumanFriendlyTestCase.test_compact_empty_linesU  s     #5))U2222"7++w6666":..*<<<<"<00L@@@@">22lBBBB"#344DDDD"#566,FFFFFFrz   c                     t          d          dk    sJ t          dd          dk    sJ t          dd          d	k    sJ d
S )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    rx   test_dedentz!HumanFriendlyTestCase.test_dedentd  s    /004GGGGG   ?@ @ @ @     <= = = = = =rz   c                     t          dd          dk    sJ t          dd          dk    sJ t          ddd          dk    sJ t          ddd          d	k    sJ d
S )z,Test :func:`humanfriendly.text.pluralize()`.rb   wordz1 wordrf   z2 wordsboxboxesz1 boxz2 boxesN)rU   r   s    rx   test_pluralizationz(HumanFriendlyTestCase.test_pluralizationn  sx    F##x////F##y0000E7++w6666E7++y888888rz   c                    |                      dt          d                     |                      dt          d                     |                     t                    5  t          d           ddd           n# 1 swxY w Y   |                     t                    5  t          d           ddd           dS # 1 swxY w Y   dS )z0Test :func:`humanfriendly.text.generate_slug()`.zsome-random-textzSome Random Text! N-)r   rT   r   r   r   s    rx   test_generate_slugz(HumanFriendlyTestCase.test_generate_slugu  sA    	+];N-O-OPPP+];M-N-NOOOz** 	 	#	 	 	 	 	 	 	 	 	 	 	 	 	 	 	z** 	 	#	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s$   !A==BB"B??CCc                 *   dD ]%}|                      dt          |                     &dD ]%}|                      dt          |                     &|                     t                    5  t          d           ddd           dS # 1 swxY w Y   dS )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   )rv   values     rx   test_boolean_coercionz+HumanFriendlyTestCase.test_boolean_coercion  s    E 	: 	:ET>%#8#89999I 	; 	;EUN5$9$9::::z** 	, 	,?+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,s   +BBBc                    t          j        d          }t          t          d          t	          |                    sJ |t          |          u sJ t          dt           j                  }|                    d          sJ |                     t                    5  t          g            ddd           dS # 1 swxY w Y   dS )z,Test :func:`humanfriendly.coerce_pattern()`. foobarFOOBARN)	recompile
isinstancer	   r   
IGNORECASEmatchr   r   )rv   empty_patternpatterns      rx   test_pattern_coercionz+HumanFriendlyTestCase.test_pattern_coercion  s    
2.22D4G4GHHHHH} = ===== 2=99}}X&&&&&z** 	 	2	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   B<<C C c                    d}|dz  }|dz  }|dz  }|dz  }dt          dd          k    sJ d	t          d
d          k    sJ dt          dd          k    sJ dt          dd          k    sJ dt          dd          k    sJ dt          dd          k    sJ dt          dd          k    sJ dt          d          k    sJ dt          d          k    sJ dt          d          k    sJ dt          t          j                  k    sJ dt          |          k    sJ dt          d          k    sJ dt          |d z            k    sJ d!t          |          k    sJ d"t          |d z            k    sJ d#t          |          k    sJ d$t          |d z            k    sJ d%t          |          k    sJ d&t          |d z            k    sJ d't          |          k    sJ d(t          |d z            k    sJ d)t          |d*z  |d+z  z   |d,z  z   |d-z  z   |d z  z   dz   d          k    sJ d.t          ||d z  z   |d-z  z   |d/z  z             k    sJ d0t          d1d          k    sJ d2t          d1d          k    sJ d3t          d4          k    sJ d5t          d6          k    sJ d7t          d8d          k    sJ d9t          d:d          k    sJ d;t          d<d          k    sJ t          j                                        }|t          j        d=>          z
  }d?t          ||z
            k    sJ d@S )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 secondrb   z3.14 seconds1 minutez1 minute and 20 secondsP   	2 minutesrf   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)rv   minutehourdayweekyearrA  thens           rx   test_format_timespanz*HumanFriendlyTestCase.test_format_timespan  sF   {RiQwbyt!L!L!LLLLL OI$M$M$MMMMM/(T"J"J"JJJJJ!_Vd%K%K%KKKKK/%$"G"G"GGGGG!_S4%H%H%HHHHHe D D DDDDDoa000000!9!99999_Q//////!9!99999_V444444(OB,?,?????ofqj999999?4000000OD1H555555/#......?37333333?4000000OD1H555555?4000000OD1H555555RD1Htax/#'9D1HDvPQzQTWWbfgggh h h h+D4!8OcAg5r	ABBC C C C 9OE\`<a<a<aaaaa)_UU-S-S-SSSSS *_V-D-DDDDD*og.F.FFFFF-QU1V1V1VVVVV/?6TX3Y3Y3YYYYY1_ZZ^5_5_5_____ ##%%X'b1111_S4Z88888888rz   c                    |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d	                     |                      d
t          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                      |                      d!t          d"                     |                      d!t          d#                     |                     t                    5  t          d$           d%d%d%           d%S # 1 swxY w Y   d%S )&z,Test :func:`humanfriendly.parse_timespan()`.r   r  0sr%  1nsgbak>51nsr'  1usg'eRC?52usr)  1msr(  r+  r*  r,  r8  5sz	5 secondsx   2mr0     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    rx   test_parse_timespanz)HumanFriendlyTestCase.test_parse_timespan  s!   N3//000N400111nU&;&;<<<nV&<&<===>%#8#8999>&#9#9:::u 5 5666 ? ?@@@n-?@@AAAn];;<<<N400111N;77888!5!5666!<!<===!8!8999!9!9:::nU&;&;<<<nY&?&?@@@)>$+?+?@@@)>(+C+CDDD-~e/D/DEEE-~i/H/HIII// 	! 	!4   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!s   L::L>L>c                 \   |                      dt          d                     |                      dt          d                     |                      dt          d                     |                     t                    5  t          d           ddd           dS # 1 swxY w Y   dS )	z(Test :func:`humanfriendly.parse_date()`.)  r7     r   r   r   z
2013-06-17)rY  r7  rZ  rf   /   rj   z2013-06-17 02:47:42)i  rn      r   r[  rZ  z2016-11-30 00:47:17z
2013-06-XYN)r   r   r   r   r   s    rx   test_parse_datez%HumanFriendlyTestCase.test_parse_date  s    /L1I1IJJJ1:>S3T3TUUU2J?U4V4VWWW{++ 	% 	%|$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%s   B!!B%(B%c                    |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      d	t          d
                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          dd                     |                      dt          dd                     |                      dt          dd                     |                      dt          d d                     |                      d!t          d"d                     |                      d#t          d$d                     |                      d%t          d&d                     |                      d't          d(d                     |                      d)t          d*                     |                      d+t          d,                     d-S ).z)Test :func:`humanfriendly.format_size()`.z0 bytesr   z1 byterb   z42 bytesrj   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    rx   test_format_sizez&HumanFriendlyTestCase.test_format_size  s   KNN333;q>>222[__555Y!7!7888Y!7!7888Y!7!7888Y!7!7888Y!7!7888Y!7!7888Y!7!7888Y!7!7888+i"E"E"EFFF+i"E"E"EFFF+i"E"E"EFFF+i"E"E"EFFF+i"E"E"EFFF+i"E"E"EFFF+i"E"E"EFFF+i"E"E"EFFF+i"8"8999;#?#?@@@@@rz   c                    |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          dd	
                     |                      dt          d                     |                      dt          d                     |                      dt          dd	
                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                     t                    5  t          d           d d d            n# 1 swxY w Y   |                     t                    5  t          d!           d d d            d S # 1 swxY w Y   d S )"z(Test :func:`humanfriendly.parse_size()`.r   0Brj   4242Br`  1krn  Tro  r_  z
1 kilobytei@z69 MBrc  rb  re  rd  rg  rf  ri  rh  rk  rj  rm  rl  g   ZAz1.5 GBg      Dz1.5 YiB1qNr   )r   r   r   r   r   s    rx   test_parse_sizez%HumanFriendlyTestCase.test_parse_size  s   Jt,,---Z--...Z..///z$//000z$t<<<===z&11222z,77888z,tDDDEEEG)<)<===Jv$6$6777Jv$6$6777Jv$6$6777Jv$6$6777Jv$6$6777Jv$6$6777*X*>*>???*Y*?*?@@@{++ 	 	t	 	 	 	 	 	 	 	 	 	 	 	 	 	 	{++ 	 	sOOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s$   2JJJ3KKKc                 6   |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      d	t          d
                     |                      dt          d                     |                      dt          d                     |                      dt          d                     dS )z+Test :func:`humanfriendly.format_length()`.z0 metresr   z1 metrerb   z	42 metresrj   z1 kmr`  15.3 cm/$?z1 cm{Gz?z1 mmr)  z1 nmr%  N)r   r
   r   s    rx   test_format_lengthz(HumanFriendlyTestCase.test_format_length  s    ]1%5%5666M!$4$4555mB&7&7888x!8!8999M%$8$8999u!5!5666u!5!5666u!5!566666rz   c                    |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          d	                     |                      d
t          d                     |                      dt          d                     |                      dt          d                     |                      dt          d                     |                     t                    5  t          d           ddd           n# 1 swxY w Y   |                     t                    5  t          d           ddd           dS # 1 swxY w Y   dS )z*Test :func:`humanfriendly.parse_length()`.r   0mrj   ru        ?1.542mr`  1kmr|  r{  r}  1cmr)  1mmr%  1nmrV  Nr   )r   r   r   r   r   s    rx   test_parse_lengthz'HumanFriendlyTestCase.test_parse_length(  s   L..///\$//000l511222\%00111|E22333Y 7 7888U 3 3444U 3 3444U 3 3444}-- 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	}-- 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s$   E22E69E6F44F8;F8c                    |                      dt          d                     |                      dt          d                     |                      dt          d                     |                      dt          dd                     |                      d	t          d
                     |                      d	t          dd                     |                      dt          d                     |                      dt          d                     |                      dt          d                     dS )z+Test :func:`humanfriendly.format_number()`.r  rb   r  r  z1.56gg?z1.567r:  z1,000r`  g)\@@r   z	1,000,000ra  z1,000,000.42gq=
׀.Az-285.67gQqN)r   r   r   s    rx   test_format_numberz(HumanFriendlyTestCase.test_format_number8  s   mA..///c 2 2333w!7!7888-";";<<<-"5"5666-";";<<<mG&<&<===z)B)BCCCM'$:$:;;;;;rz   c                 "   |                      dt          d                     |                      dt          d                     |                      dt          dd                     |                      dt          d                     d	S )
z*Test :func:`humanfriendly.round_number()`.r  rb   g      ?1.00T
keep_widthz3.14g-DT!	@N)r   r   r   s    rx   test_round_numberz'HumanFriendlyTestCase.test_round_numberE  s    l1oo...l3//000aD!A!A!ABBB.?!@!@AAAAArz   c                     t           j                            dd          }t           j                            t           j        d         d          }|                     |t          |                     dS )z)Test :func:`humanfriendly.format_path()`.~.vimrcHOMEN)r   r   r   environr   r   rv   friendly_pathabsolute_paths      rx   test_format_pathz&HumanFriendlyTestCase.test_format_pathL  sW    S(33RZ%7BBM(B(BCCCCCrz   c                     t           j                            dd          }t           j                            t           j        d         d          }|                     |t          |                     dS )z(Test :func:`humanfriendly.parse_path()`.r  r  r  N)r   r   r   r  r   r   r  s      rx   test_parse_pathz%HumanFriendlyTestCase.test_parse_pathR  sW    S(33RZ%7BB
=(A(ABBBBBrz   c                 &   dgg}t          |          t          d                                          k    sJ g dg dg}t          |          t          d                                          k    sJ g d}g dg dg}t          t          ||                    t          d                                          k    sJ dd	g}d
dgddgg}t          t          ||                    t          d                                          k    sJ dS )z8Test :func:`humanfriendly.tables.format_pretty_table()`.zJust one columnzi
            -------------------
            | Just one column |
            -------------------
        rg   rh   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   )rv   datacolumn_namess      rx   test_pretty_tablesz(HumanFriendlyTestCase.test_pretty_tablesX  sw    ##$"4((F 4 - - UWW	    (''9"4((F 4 - -
 UWW    /..1-dLAABBf N G G UWW    '(;<D!Iu#56-dLAABBf N G G UWW     rz   c                 >   g d}g dg dg}t          t          ||                    t          d                                          k    sJ g d}g dg dg}t          t          ||                    t          d                                          k    sJ dS )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  rv   r  r  s      rx   test_robust_tablesz(HumanFriendlyTestCase.test_robust_tables  s    ...1-dLAABBf 
N 
G 
G UWW
 
 
 
 /..!O!O!OP-dLAABBf N G G UWW     rz   c                 >   g d}g dg dg}t          t          ||                    t          d                                          k    sJ g d}g dg dg}t          t          ||                    t          d                                          k    sJ dS )z7Test :func:`humanfriendly.tables.format_smart_table()`.r  r  r  r  r  r  N)r4   r-   rS   r  r  s      rx   test_smart_tablesz'HumanFriendlyTestCase.test_smart_tables  s    ...1,T<@@AAV M F F UWW    /..!O!O!OP,T<@@AAV M F F UWW     rz   c                 8   g d}g dg dg}|                      t          ||          t          d                                                     g dg dg}|                      t          |          t          d                                                     dS )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      rx   test_rst_tablesz%HumanFriendlyTestCase.test_rst_tables  s     /..1T<00    
	
 
	
 
	
  1T""   
 	
 	
 	
 	
 	
rz   c                    t          g           dk    sJ t          dg          dk    sJ t          ddg          dk    sJ t          g d          dk    sJ t          g dd          d	k    sJ t          g dd
          dk    sJ dS )z.Test :func:`humanfriendly.text.concatenate()`.r  rc   re   zone and two)rc   re   threezone, two and threeor)conjunctionzone, two or threeT)serial_commazone, two, and threeNrR   r   s    rx   test_concatenatez&HumanFriendlyTestCase.test_concatenate  s    2"$$$$E7##u,,,,E5>**m;;;;222337KKKKK222EEEI\\\\\222FFFJ_______rz   c                 V   ddl m} |                      |d          g            |                      |d          dg           |                      |d          ddg           |                      |d          g d           |                      |d	          g d           d
S )z(Test :func:`humanfriendly.text.split()`.r   )splitr  r   zfoo, barbarzfoo, bar, bazr   r  bazzfoo,bar,bazN)humanfriendly.textr  r   )rv   r  s     rx   
test_splitz HumanFriendlyTestCase.test_split  s    ,,,,,,rB'''uw///z**UEN;;;//1F1F1FGGG}--/D/D/DEEEEErz   c                 \   dD ]x\  }}t          t          j                    |z
            }|                     t          |j        d          d|z             |                     t          |          |           yt          t          j                    dz
            }|                     |j        d           t                      }t          j        d           |                     t          |j        d          d	           t          d
          }t          d          D ]0}|5  t          j        d           ddd           n# 1 swxY w Y   1|                     t          |j        d          d           t          d
          5 }|J 	 ddd           dS # 1 swxY w Y   dS )z!Test :func:`humanfriendly.Timer`.)
)rb   r-  )rf   	2 seconds)r!  r.  )rR  r0  )i  r1  )i   r2  )iQ r3  )i  r4  )i:	 r5  )i u r6  Tr  z%i.00g@r  rb   r   r  )	resumablerf   Nz2.00)
r   timer   r   elapsed_timestrroundedsleepnormalize_timestamprange)rv   secondstexttautomatic_timerresumable_timeritimers           rx   
test_timerz HumanFriendlyTestCase.test_timer  s   	A 	+ 	+MGT dikkG+,,A\!.TJJJGV]L]^^^SVVT****$)++#$$K000''
1
 	,_-I1MMvVVV$///q 	 	A   
1              ,_-I1MMvVVVT""" 	%e$$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%s$   (E		E	E	F!!F%(F%c                    t                      }t          dd|d          }dD ],}|                    |           t          j        d           -|                                 |                                } |j        t          d                              t          d          }d	  |j
        t                    D             }|                     t          |          d
k               |                     t          d |D                                  |                     t          d |D                                  |                     t!          t#          |                    t!          |                     dS )z#Test :func:`humanfriendly.Spinner`.test spinnerr9  T)labeltotalstreaminteractive)rb   rf   r:  r9  )progressg?r  c                     g | ]}||S r   r   .0lines     rx   
<listcomp>z6HumanFriendlyTestCase.test_spinner.<locals>.<listcomp>  s    HHH$4HHHHrz   r   c              3      K   | ]}d |v V  	dS )r  Nr   r  s     rx   	<genexpr>z5HumanFriendlyTestCase.test_spinner.<locals>.<genexpr>  s'      EEtNd2EEEEEErz   c              3      K   | ]}d |v V  	dS )%Nr   r  s     rx   r  z5HumanFriendlyTestCase.test_spinner.<locals>.<genexpr>  s&      ::DC4K::::::rz   N)r   rD   stepr  r  cleargetvaluereplacer3   r0   r  r/   
assertTruerp   allr   sortedset)rv   r  spinnerr  r=   liness         rx   test_spinnerz"HumanFriendlyTestCase.test_spinner  sT   aTXYYY$ 	 	HLL(L+++JsOOOO"" &.!1266 !1266 	HH,&,"?"?HHHE

Q'''EEuEEEEEFFF::E:::::;;;E

++VE]];;;;;rz   c                     t          d          5  t          j        d           ddd           dS # 1 swxY w Y   dS )a  
        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  rb   N)rC   r  r  r   s    rx   test_automatic_spinnerz,HumanFriendlyTestCase.test_automatic_spinner   s     N333 	 	JqMMM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   377c                 j   |                      t                    5  t          g            ddd           n# 1 swxY w Y   t          t          j                  5 }t          t          d|          5  d}t          |g          |k    sJ 	 ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   t          t          dd           5  t          ddg          dk    sJ 	 ddd           n# 1 swxY w Y   t          t          dd           5  t          ddg          dk    sJ 	 ddd           n# 1 swxY w Y   t          t          dd	           5  t          ddg          dk    sJ 	 ddd           n# 1 swxY w Y   t          t          dd
           5  t          ddgd          dk    sJ 	 ddd           n# 1 swxY w Y   g dt          t          dfd          5  t          g d          dk    sJ 	 ddd           n# 1 swxY w Y   ddgt          t          dfd          5  t          g d          dk    sJ 	 ddd           n# 1 swxY w Y   ddgt          t          dfd          5  t          g d          dk    sJ 	 ddd           n# 1 swxY w Y   t          t          dd           5  |                      t                    5  t          g d           ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )z7Test :func:`humanfriendly.prompts.prompt_for_choice()`.Nr   zonly one option (shortcut)interactive_promptc                     dS )Nr   r   ps    rx   r   z>HumanFriendlyTestCase.test_prompt_for_choice.<locals>.<lambda>:  s    u rz   r   r  c                     dS )Nfr   r  s    rx   r   z>HumanFriendlyTestCase.test_prompt_for_choice.<locals>.<lambda>=      s rz   c                     dS )Nr  r   r  s    rx   r   z>HumanFriendlyTestCase.test_prompt_for_choice.<locals>.<lambda>@  r  rz   c                     dS Nr  r   r  s    rx   r   z>HumanFriendlyTestCase.test_prompt_for_choice.<locals>.<lambda>C      r rz   default)r  qzc                 .                         d          S Nr   rt   r  repliess    rx   r   z>HumanFriendlyTestCase.test_prompt_for_choice.<locals>.<lambda>G      w{{ST~~ rz   r  r  r   r  c                 .                         d          S r  r  r  s    rx   r   z>HumanFriendlyTestCase.test_prompt_for_choice.<locals>.<lambda>K  r  rz   )r   r  r  quxr  ru  r  c                 .                         d          S r  r  r  s    rx   r   z>HumanFriendlyTestCase.test_prompt_for_choice.<locals>.<lambda>O  r  rz   c                     dS r  r   r  s    rx   r   z>HumanFriendlyTestCase.test_prompt_for_choice.<locals>.<lambda>R  r  rz   r  )
r   r   r"   r   r   devnullrH   r   r   r    )rv   r   only_optionr  s      @rx   test_prompt_for_choicez,HumanFriendlyTestCase.test_prompt_for_choice-  s    z** 	" 	"b!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"
 "* 	G!#w77 G G:(+77;FFFFFG G G G G G G G G G G G G G G	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G
 g';__MM 	> 	>$eU^44=====	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> g';]]KK 	> 	>$eU^44=====	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> g';]]KK 	> 	>$eU^44=====	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> g';\\JJ 	M 	M$eU^UCCCuLLLLL	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M !..g';=U=U=U=UVV 	E 	E$%:%:%:;;uDDDDD	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E *g';=U=U=U=UVV 	L 	L$%A%A%ABBeKKKKK	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L +g';=U=U=U=UVV 	E 	E$%:%:%:;;uDDDDD	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E g';\\JJ 	3 	3""#899 3 3!///2223 3 3 3 3 3 3 3 3 3 3 3 3 3 3	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3s   8<<B03BB0B	B0 B	!B00B47B4C77C;>C;D>>EE FF	F	'GGG6HH"HI((I,/I,J55J9<J9L(2LL(L	L(L	L((L,/L,c                    dD ]Gt          t          dfd          5  t          d          du sJ 	 ddd           n# 1 swxY w Y   HdD ]Gt          t          dfd          5  t          d          d	u sJ 	 ddd           n# 1 swxY w Y   Hd
D ]G}t          t          dd           5  t          d|          |u sJ 	 ddd           n# 1 swxY w Y   Hddgt          t          dfd          5  t          d          5 }t          d          du sJ d|                                v sJ 	 ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   t          t          dd           5  dD ][\  }}t          d          5 }t          d|          du sJ ||                                v sJ 	 ddd           n# 1 swxY w Y   \	 ddd           n# 1 swxY w Y   t          t          dd           5  |                     t                    5  t          d           ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )z=Test :func:`humanfriendly.prompts.prompt_for_confirmation()`.)r   YesYESyYr  c                     S r   r   r  replys    rx   r   zDHumanFriendlyTestCase.test_prompt_for_confirmation.<locals>.<lambda>Z      5 rz   zAre you sure?TN)r  NoNOnNc                     S r   r   r  s    rx   r   zDHumanFriendlyTestCase.test_prompt_for_confirmation.<locals>.<lambda>^  r  rz   F)TFc                     dS r  r   r  s    rx   r   zDHumanFriendlyTestCase.test_prompt_for_confirmation.<locals>.<lambda>b  s    2 rz   r  r  r  c                 .                         d          S r  r  r  s    rx   r   zDHumanFriendlyTestCase.test_prompt_for_confirmation.<locals>.<lambda>f  r  rz   mergedzthere's no default choicec                     dS )Nr  r   r  s    rx   r   zDHumanFriendlyTestCase.test_prompt_for_confirmation.<locals>.<lambda>k  r  rz   ))TzY/n)Fzy/N)Nzy/nc                     dS r  r   r  s    rx   r   zDHumanFriendlyTestCase.test_prompt_for_confirmation.<locals>.<lambda>q  r  rz   )rH   r   r!   rF   get_textr   r    )rv   default_choicer   default_valueexpected_textr  r  s        @@rx   test_prompt_for_confirmationz2HumanFriendlyTestCase.test_prompt_for_confirmationV  s    3 	H 	HE!'+?QQ H H.??4GGGGGH H H H H H H H H H H H H H H 0 	I 	IE!'+?QQ I I.??5HHHHHI I I I I I I I I I I I I I I * 	j 	jN!'+?NN j j.WWW[iiiiiij j j j j j j j j j j j j j j s)g';=U=U=U=UVV 	J 	Jd+++ Jx.??4GGGG2h6G6G6I6IIIIIIJ J J J J J J J J J J J J J J	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J
 g';]]KK 	@ 	@0\ @ @,}"$/// @82?MZZZ^bbbbb(H,=,=,?,??????@ @ @ @ @ @ @ @ @ @ @ @ @ @ @@	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ g';\\JJ 	9 	9""#899 9 9'8889 9 9 9 9 9 9 9 9 9 9 9 9 9 9	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9s   AA	A	*BB	B	2CC	C	>E,E<EE	EE	EE#&E#G-.GG-GG-GG--G14G1I*I:II
	
II
	II"%I"c                 z   t          t          j                  5 }t          t          d|          5  d}t          d|          |k    sJ |                     t                    5  t          d           ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )z6Test :func:`humanfriendly.prompts.prompt_for_input()`.r   zTo seek the holy grail!zWhat is your quest?r  zWhat is your favorite color?N)r   r   r  rH   r   r#   r   EOFError)rv   r   r$  s      rx   test_prompt_for_inputz+HumanFriendlyTestCase.test_prompt_for_inputu  s   "* 	E!#w77 E E 9'(=}UUUYfffff &&x00 E E$%CDDDE E E E E E E E E E E E E E EE E E E E E E E E E E E E E E	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	EsX   B04B%B5BBBB	BB0B	B0B	 B00B47B4c                    t          t                    \  }}d|v sJ t          t          d          \  }}d|v sJ t          t          d          \  }}|dk    sJ t          t          d          \  }} |j                    dk    sJ t          j        dd          }t          t          d	|z            \  }} |j                    t          |          k    sJ t          j        dd          }t          t          d	|z  d
          \  }} |j                    t          |d          k    sJ t          j        dd          }t          t          d|z            \  }} |j                    t          |          k    sJ t          |          dz  }t          t          d|z            \  }} |j                    t          |          k    sJ t          t          ddd          \  }} |j                    t          d                                          k    sJ t          j        dd          }t          t          d|z            \  }} |j                    t          |          k    sJ t          t          d          \  }}t          |          t          d          k    sJ t          t          d          \  }}t          |          t          dd          k    sJ t          t          d          \  }}t          |          t          d          k    sJ t          t          d          \  }}t          |          t          d          k    sJ t          t          d d!d"d#          \  }}|d$k    sJ t          t          d%          \  }}|dk    sJ d&  |j                    D             }d'|v sJ d(|v sJ d)|v sJ d*|v sJ d+|v sJ d,|v sJ d-|v sJ d.S )/z Test the command line interface.zUsage:z--helpz--unsupported-optionr   z--format-number=1234567z	1,234,567rn  rq  z--format-size=%iz--binaryTro  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 |
            -------------
        r8  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 42rj   z--democ                 ,    g | ]}t          |          S r   )r4   r  s     rx   r  z2HumanFriendlyTestCase.test_cli.<locals>.<listcomp>  s     BBBdD!!BBBrz   z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   
splitlines)rv   r   r=   random_byte_count
random_lenrandom_timespanr  s          rx   test_clizHumanFriendlyTestCase.test_cli  s@    %T]]
F6!!!!$T844
F6!!!!$T+ABB
FQ$T+DEE
Fv|~~,,,,"N4==$T+=@Q+QRR
Fv|~~->!?!?????"N4==$T+=@Q+QS]^^
Fv|~~->t!L!L!LLLLL^D+66
$T+?*+LMM
Fv|~~z!:!::::::&&0
$T+?*+LMM
Fv|~~z!:!:::::$T+;=MUpqqq
Fv|~~ ) " " UWW    !.C00$T+AO+STT
Fv|~~!A!AAAAA$T+>??
F6{{j000000$T+?@@
F6{{j=======$T+@AA
F6{{l6222222$T+CDD
FV}}Y 7 77777$T?FDJ^__
FR %T844
FQBB.?f.?.A.ABBB&&&&#u,,,,#u,,,,2e;;;;8EAAAA-66664======rz   c                    t          d          t          dt          k    sJ t          d          t          dt          k    sJ t          d          t          dt          k    sJ t          d          t          d	t          k    sJ t          d
          t          dt          k    sJ t          d          t          dt          k    sJ t          d          t          dt          k    sJ t          d          t          dt          k    sJ t          dd          t          dt          k    sJ t          d          t          dt          k    sJ t          d          t          dt          k    sJ t          d          t          dt          k    sJ t          d          t          dt          k    sJ t          d          t          dt          k    sJ |                     t                    5  t          d           ddd           dS # 1 swxY w Y   dS ) z1Test :func:`humanfriendly.terminal.ansi_style()`.Tboldr  )faintr  )italicr  )	underline4)inverse7)strike_through9bluecolor34)
background44)rB  bright94   z38;5;214z39;5;214)r   r   r   z
38;2;0;0;0)   rI  rI  z38;2;255;255;255)2   d      z48;2;50;100;150unknownN)r5   r.   r2   r   r   r   s    rx   test_ansi_stylez%HumanFriendlyTestCase.test_ansi_style  s   t$$$888XX(FFFFF%%%HHHhh)GGGGG&&&XXXxx*HHHHHD)))((-KKKKK$'''hhh+IIIII...XXXxx2PPPPP'''xxx+JJJJJV,,,HHHhh0OOOOOt444HHHhh8WWWWW$$$(((HH(MMMMMS)))xxx-RRRRR	***(((HH.UUUUU000hhhX`X`4aaaaa^444QYQYQY[c[c8dddddz** 	( 	(Y''''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(s   "I  IIc                    d}t          |          t          |          k    sJ t          |d          }||k    sJ t          |          t          |          k    sJ t          |          t          |          k    sJ dS )z1Test :func:`humanfriendly.terminal.ansi_width()`.WhateverTr6  N)rp   r6   r7   )rv   r  wrappeds      rx   test_ansi_widthz%HumanFriendlyTestCase.test_ansi_width  s    4yyJt,,,,,,Dt,,,$7||c$ii''''4yyJw////////rz   c                     d}|t          |          k    sJ t          |d                              t                    sJ t          |d                              t                    sJ dS )z0Test :func:`humanfriendly.terminal.ansi_wrap()`.rP  Tr6  N)r7   
startswithr.   endswithr1   rv   r  s     rx   test_ansi_wrapz$HumanFriendlyTestCase.test_ansi_wrap  sr    y&&&&D)))44X>>>>>D)))22:>>>>>>>rz   c                    t          d          dk    sJ t          d          dk    sJ t          d          dk    sJ t          d          dk    sJ t          d          dk    sJ t          d	          d
k    sJ t          d          d
k    sJ t          d          dk    sJ t          d          dk    sJ t          d          dk    sJ t          d          dk    sJ t          d          dk    sJ t          d          dk    sJ t          d          dk    sJ t          d          dk    sJ t          d          dk    sJ t          d          dk    sJ t          d          dk    sJ t          d          d k    sJ t          d!          dk    sJ d" }d#t          d$|%          vsJ d#t          d&|%          v sJ t          d'          sJ d(S ))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                 .    |                      dd          S )N:wink:z;-))r  )r  s    rx   callbackz9HumanFriendlyTestCase.test_html_to_ansi.<locals>.callback'  s    <<%000rz   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   )rv   r^  s     rx   test_html_to_ansiz'HumanFriendlyTestCase.test_html_to_ansi  s   2337MMMMMIJJ]^ ^ ^ ^ ^__;< < < < 3448]]]]]UVV12 2 2 2 56634 4 4 4XYY34 4 4 4 <==67 7 7 7cdd67 7 7 7 =>>;< < < <kll;< < < < BCC;< < < < VWWGH H H H oppJK K K K >??*+ + + + G$$++++G$$++++F##s****F##s****H%%,,,,	1 	1 	1 |OhOOOOOOO<(=QQQQQQQ     	 	 	 	 	rz   c                 0   d}t          d          5 }t          |           |                     |g|j                                                   |                     g |j                                                   ddd           dS # 1 swxY w Y   dS )z:Test the :func:`humanfriendly.terminal.output()` function.z%Standard output generated by output()Fr  N)rF   r=   r   r   r   r   rv   r  r   s      rx   test_generate_outputz*HumanFriendlyTestCase.test_generate_output9  s    6%((( 	>H4LLLdVX_%>%>%@%@AAAR!:!:!<!<===	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>   A+BBBc                 0   d}t          d          5 }t          |           |                     g |j                                                   |                     |g|j                                                   ddd           dS # 1 swxY w Y   dS )z;Test the :func:`humanfriendly.terminal.message()` function.z%Standard error generated by message()Fr  N)rF   r<   r   r   r   r   ra  s      rx   test_generate_messagez+HumanFriendlyTestCase.test_generate_messageA  s    6%((( 	BHDMMMR!:!:!<!<===dVX_%>%>%@%@AAA	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	Brc  c                 T   ddl m} d} |d          5 }t          |           |                     g |j                                                   |                     t          |d          g|                     |j                             ddd           dS # 1 swxY w Y   dS )	z;Test the :func:`humanfriendly.terminal.warning()` function.r   rF   z%Standard error generated by warning()Fr  redrA  N)	r   rF   r@   r   r   r   r7   ignore_coverage_warningr   )rv   rF   r  r   s       rx   test_generate_warningz+HumanFriendlyTestCase.test_generate_warningI  s   ******6]%((( 	lHDMMMR!:!:!<!<===iE:::;T=Y=YZbZi=j=jkkk	l 	l 	l 	l 	l 	l 	l 	l 	l 	l 	l 	l 	l 	l 	l 	l 	l 	ls   A;BB!$B!c                 >    d |                                 D             S )a  
        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)
        c                     g | ]}d |v|	S )zno-data-collectedr   r  s     rx   r  zAHumanFriendlyTestCase.ignore_coverage_warning.<locals>.<listcomp>[  s$    WWW7JRV7V7V7V7V7Vrz   )r   )rv   r  s     rx   ri  z-HumanFriendlyTestCase.ignore_coverage_warningR  s%     XW!1!1!3!3WWWWrz   c                    t          d          dgk    sJ t          d          ddgk    sJ t          d          ddgk    sJ t          d          dgk    sJ t          d          dgk    sJ t          d	          g d
k    sJ dS )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    rx   test_clean_outputz'HumanFriendlyTestCase.test_clean_output]  s     %U++w6666$Z00UENBBBB$_55%GGGG$Y//E7::::$Z00UG;;;;$%:;;?T?T?TTTTTTTrz   c                    t                      \  }}|dk    sJ |dk    sJ t          j        }t          j        }t          j        }	 t                      t          _        t                      t          _        t                      t          _        t                      \  }}|dk    sJ |dk    sJ t          j        d         }	 dt          j        d<   t                      \  }}|dk    sJ |dk    sJ 	 |t          j        d<   n# |t          j        d<   w xY w	 |t          _        |t          _        |t          _        dS # |t          _        |t          _        |t          _        w xY w)z9Test :func:`humanfriendly.terminal.find_terminal_size()`.r   PATHr  N)r:   r   r   r   r   r   r   r  )rv   r  columnssaved_stdinsaved_stdoutsaved_stderr
saved_paths          rx   test_find_terminal_sizez-HumanFriendlyTestCase.test_find_terminal_sizel  sF   +--w qyyyy{{{{
 izz	& 

CI!CJ!CJ 011NE719999Q;;;; F+J0%'
6"!3!5!5wqyyyy{{{{{%/
6""Z
6"////"#CI%CJ%CJJJ $CI%CJ%CJ%%%%s%   A;D? 0D 4D? DD? ?&E%c                 z   ddl m} t          t          fD ]}t          j        t          j        fD ]2} |            5   ||          sJ 	 ddd           n# 1 swxY w Y   3t          t          j	                  5 } ||          rJ 	 ddd           n# 1 swxY w Y    |t                                rJ dS )z8Test the functions that check for terminal capabilities.r   rg  N)r   rF   r9   r?   r   r   r   r   r   r  r   )rv   rF   test_streamr  r   s        rx   test_terminal_capabilitiesz0HumanFriendlyTestCase.test_terminal_capabilities  sd   ******02JJ 	- 	-K
 *cj0 / /"]__ / /&;v....../ / / / / / / / / / / / / / / bj!! /V&;v....../ / / / / / / / / / / / / / / #{688,,,,,,	- 	-s#   AAA;BB	B	c                 *   t           j                            dd          }	 dt           j        d<   d                    d t	          d          D                       }t                      5 }t          |           ||                                v sJ 	 ddd           n# 1 swxY w Y   ||t           j        d<   dS t           j                            d           dS # ||t           j        d<   w t           j                            d           w xY w)z1Test :func:`humanfriendly.terminal.show_pager()`.PAGERNcatr   c              3   4   K   | ]}t          d           V  dS )   N)rV   )r  r  s     rx   r  z8HumanFriendlyTestCase.test_show_pager.<locals>.<genexpr>  s*      #I#I!M"$5$5#I#I#I#I#I#Irz   rJ  )	r   r  rs   r   r  rF   r>   r"  rt   )rv   original_pagerrandom_textr   s       rx   test_show_pagerz%HumanFriendlyTestCase.test_show_pager  sF   66	( #(BJw ))#I#IuRyy#I#I#IIIK :H;'''"h&7&7&9&999999: : : : : : : : : : : : : : : )&4
7### 
w''''' )&4
7## 
w''''s0   A	C +(B C  B$$C 'B$(C 3Dc                 P   dt          d          vsJ dt          t          dd                    v sJ ddg}dD ]}t          j                            dd	          }	 |t          j        d<   t                      |d
k    rt          fd|D                       sJ nt          fd|D                       rJ ||t          j        d<   t          j                            d           # ||t          j        d<   w t          j                            d           w xY wd	S )z8Test :func:`humanfriendly.terminal.get_pager_command()`.z--RAW-CONTROL-CHARSzUsage messageTr6  z	--no-initz--quit-if-one-screen)r}  lessr|  Nr  c              3       K   | ]}|v V  	d S r   r   r  optcommand_lines     rx   r  z?HumanFriendlyTestCase.test_get_pager_command.<locals>.<genexpr>  s(      WWssl2WWWWWWrz   c              3       K   | ]}|v V  	d S r   r   r  s     rx   r  z?HumanFriendlyTestCase.test_get_pager_command.<locals>.<genexpr>  s(      "["[33,#6"["["["["["[rz   )r;   r7   r   r  rs   r  anyrt   )rv   options_specific_to_lesspagerr  r  s       @rx   test_get_pager_commandz,HumanFriendlyTestCase.test_get_pager_command  s_    %,=o,N,NNNNN$(9)OZ^:_:_:_(`(`````$/1G#H " 	, 	,EZ^^GT::N,&+
7#022F??WWWW>VWWWWWWWWW""["["["[BZ"["["[[[[[[!-*8BJw'' JNN7++++ "-*8BJw'' JNN7++++%	, 	,s    AC003D#c                 h    t          t          d                    t          g d          k    sJ dS )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    rx   test_find_meta_variablesz.HumanFriendlyTestCase.test_find_meta_variables  sS    ) +    
 555667 7 7 7 7 7rz   c                 r    |                      d          \  }}d|v sJ d|v sJ d|v sJ d|v sJ d|v sJ dS )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rv   introductionoptionss      rx   test_parse_usage_simplez-HumanFriendlyTestCase.test_parse_usage_simple  s~     $ < < 
> 
! 
!g /,>>>>$4444#|3333w&&&&,777777rz   c                     |                      d          \  }}d|v sJ t          d |D                       sJ d|v sJ d|v sJ d|v sJ d|v sJ d|v sJ d	S )
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      K   | ]}d |v V  	dS )zstill part of the introductionNr   r  r  s     rx   r  z@HumanFriendlyTestCase.test_parse_usage_tricky.<locals>.<genexpr>  s(      OOQ3q8OOOOOOrz   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      rx   test_parse_usage_trickyz-HumanFriendlyTestCase.test_parse_usage_tricky  s     $ < < > ! !g, /,>>>>OO,OOOOOOOO#|3333(G3333;wFFFF&'11119WDDDDDDrz   c                     |                      d          \  }}d|v sJ d|v sJ d|v sJ d|v sJ d|v sJ d|v sJ d|v sJ d	S )
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      rx   test_parse_usage_commasz-HumanFriendlyTestCase.test_parse_usage_commas  s     $ < < > ! !g  /,>>>>-====#|3333#w....-8888/7::::@GKKKKKKrz   c                 h    t          d t          t          |                    D                       S )z:Ignore leading/trailing whitespace in usage parsing tests.c              3   .   K   | ]}d  |D             V  dS )c                 6    g | ]}|                                 S r   )r  r  s     rx   r  zKHumanFriendlyTestCase.preprocess_parse_result.<locals>.<genexpr>.<listcomp>5  s     +++Aaggii+++rz   Nr   )r  rs     rx   r  z@HumanFriendlyTestCase.preprocess_parse_result.<locals>.<genexpr>5  s1      OO+++++OOOOOOrz   )tuplerZ   rS   rV  s     rx   r  z-HumanFriendlyTestCase.preprocess_parse_result3  s-    OO[5N5NOOOOOOrz   c                    d}t          |          }t          |          t          |          k    sJ |                    d          sJ d}t          |          }t          |          t          |          k    sJ ||v sJ |                    |          rJ d}t          |          }|                                }t          |d         v sJ t          |d         vsJ dS )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
rb   rf   N)rY   rp   rT  r0  r.   )rv   
usage_textformatted_textformatted_liness       rx   test_format_usagez'HumanFriendlyTestCase.test_format_usage7  s    )
%j11>""S__4444((555555
%j11>""S__4444^++++!,,Z88888: 	
 &j11(3355?1-----q1111111rz   c                     t          d          dk    sJ t          d          dk    sJ dt          t          d                    v sJ t          d dD                       sJ d	S )
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   R   K   | ]"}|t          t          d                     v V  #dS )zm
            Supported options:

              -n, --dry-run

                Don't change anything.
        N)r[   rS   )r  tokens     rx   r  z:HumanFriendlyTestCase.test_render_usage.<locals>.<genexpr>[  sZ       4 4  L 1 * *    4 4 4 4 4 4rz   )z`-n`z`--dry-run`N)r[   rS   r  r   s    rx   test_render_usagez'HumanFriendlyTestCase.test_render_usageQ  s    ;<<@eeeee0115MMMMM|F 4 - -          4 4 34 4 4 4 4 	4 	4 	4 	4 	4rz   c                 d   t          dd          d             }t                      }t          t          d|          5   |dd          dk    sJ |                     t
                    5   |ddd           ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |j        sJ dS )z.Test the deprecated_args() decorator function.r   r  c                  T    | d         dk    sJ |                      d          dv sJ dS )Nr   r  )Nr  rj   )rs   )r  s    rx   test_functionzAHumanFriendlyTestCase.test_deprecated_args.<locals>.test_functione  s9    5>U****;;u%%66662rz   warnrj   r  N)r   r\   rH   warningsr   	TypeErrorr   )rv   r  fake_fns      rx   test_deprecated_argsz*HumanFriendlyTestCase.test_deprecated_argsc  sI   		&	&	 	 
'	&	 ++h88 	3 	3 =.."4444""9-- 3 3eUE2223 3 3 3 3 3 3 3 3 3 3 3 3 3 3	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 !!!!!!s5   -B+B9BB			BB		BB #B c                 $   t                      }t          t          d|          5  t          j        t
                   }t          d          }t          ||          }|j        t          k    sJ 	 ddd           n# 1 swxY w Y   |j	        sJ dS )@Test that the DeprecationProxy class emits deprecation warnings.r  humanfriendly.text.concatenater  N)
r\   rH   r  r   modulesr   rq   r   rR   r   )rv   r  modulealiasesproxys        rx   $test_alias_proxy_deprecation_warningz:HumanFriendlyTestCase.test_alias_proxy_deprecation_warningq  s    ++h88 	4 	4[*F'GHHHG$VW55E$33333		4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4
 !!!!!!s   A
A<<B B c                 @   t          t          j        dt          j        d                    5  t          t          d           dt          t          j        t                             v sJ dt          t                    v sJ 	 ddd           dS # 1 swxY w Y   dS )r  sphinxr  r  rR   N)	rI   r   r  types
ModuleTyper   r   dirr   r   s    rx   $test_alias_proxy_sphinx_compensationz:HumanFriendlyTestCase.test_alias_proxy_sphinx_compensation{  s    h0@0J0JKK 	: 	:81QRRRR CH(=$>$>>>>> K$9$999999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:s   ABBBc                     t           j        t                   }t          t          d           |j                                        }t          ddd|d|           d                    |          |j        k    sJ dS )z?Test that aliases can be injected into generated documentation.r  r  Nappwhatr   rw   r  r  r   )r   r  r   r   __doc__r0  r$   r   )rv   r  r  s      rx   #test_alias_proxy_sphinx_integrationz9HumanFriendlyTestCase.test_alias_proxy_sphinx_integration  sw    X&x-MNNNN))++!dDfVZbghhhhyy6>111111rz   c                 ^    G d dt                     } |            }t          |           t          |j        d         k    sJ t          |j        d         k    sJ t
          |j        d         v sJ t          |j        d         v sJ t          |j        d         v sJ t          ddd|j	        dd	          d
u sJ t          ddd|j
        dd	          du sJ ddlm}m} |                     |          sJ |                     |          rJ |                     |j                  rJ dS )z,Test the :mod:`humanfriendly.sphinx` module.c                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )AHumanFriendlyTestCase.test_sphinx_customizations.<locals>.FakeAppc                 "    i | _         i | _        d S r   )	callbacksrolesr   s    rx   __init__zJHumanFriendlyTestCase.test_sphinx_customizations.<locals>.FakeApp.__init__  s    !#


rz   c                     dS )z%Documented unofficial special method.Nr   r   s    rx   __documented_special_method__z_HumanFriendlyTestCase.test_sphinx_customizations.<locals>.FakeApp.__documented_special_method__      rz   c                     d S r   r   r   s    rx   __undocumented_special_method__zaHumanFriendlyTestCase.test_sphinx_customizations.<locals>.FakeApp.__undocumented_special_method__  r  rz   c                     || j         |<   d S r   )r  )rv   r   r^  s      rx   add_rolezJHumanFriendlyTestCase.test_sphinx_customizations.<locals>.FakeApp.add_role  s    #+
4   rz   c                 b    | j                             |g                               |           d S r   )r  ru   append)rv   eventr^  s      rx   connectzIHumanFriendlyTestCase.test_sphinx_customizations.<locals>.FakeApp.connect  s.    ))%44;;HEEEEErz   c                     dS )z.Usage: This is not supposed to be reformatted!Nr   r   s    rx   bogus_usagezMHumanFriendlyTestCase.test_sphinx_customizations.<locals>.FakeApp.bogus_usage  r  rz   N)	r   r   r   r  r  r  r  r  r  r   rz   rx   FakeAppr    sq                 , , ,F F F    rz   r  manpypizautodoc-process-docstringzautodoc-skip-memberNT)r  r  r   rw   skipr  Fr   )clir  )r   r'   r%   r  r&   r$   r  r(   r)   r  r  humanfriendlyr  r  docstring_is_reformattedr  )rv   r  fake_appr  r  s        rx   test_sphinx_customizationsz0HumanFriendlyTestCase.test_sphinx_customizations  s   	 	 	 	 	f 	 	 	2 799h8>%00000HN622222(H,>?Z,[[[[['8+=>S+TTTTT%);<W)XXXXX'4d5t
 
 
 	    (4d7t
 
 
 	    	.------- ,,S11111 0088888 001EFFFFFFFrz   c                     t          |j                                                  }t          |          }t	          ddd|d|           ||k    S )zOCheck whether :func:`.usage_message_callback()` reformats a module's docstring.Nr  )rW   r  r0  listr)   )rv   entityr  saved_liness       rx   r  z.HumanFriendlyTestCase.docstring_is_reformatted  sZ     00;;==5kk4dE	
 	
 	
 	
 ##rz   N)Mr   r   r   r  ry   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  rI  rW  r]  rr  ry  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r&  r)  r4  rN  rR  rW  r_  rb  re  rj  ri  ro  rw  rz  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   rz   rx   r^   r^      s       77() () ()T
! 
! 
!F F F; ; ;- - -$, , , / / /$- - -, , ,	+ 	+ 	++ + +) ) )
( ( (
  2 2 2  C C CG G G= = =9 9 9
 
 
, , ,  09 09 09d! ! !6% % %A A A0  0	7 	7 	7   < < <B B BD D DC C C& & &P  >  8
 
 
8	` 	` 	`F F F"% "% "%H< < <"  '3 '3 '3R9 9 9>
E 
E 
EG> G> G>R( ( (&0 0 0? ? ?B B BH> > >B B Bl l l	X 	X 	XU U U(& (& (&T- - -"( ( (,, , ,87 7 78 8 8*E E EBL L L6P P P2 2 244 4 4$" " "" " ": : :2 2 28G 8G 8Gt$ $ $ $ $rz   r^   rb   c                 D    dt          t          |           |          z  S )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)roundr.  )r  r  s     rx   r  r    s"     E%,,88888rz   )rb   )vr  r@  r>  r   r   r  r   r   r  r  r   r  r  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   rz   rx   <module>r     s	   2 1   				  				     



                                             * G F F F F F F F " " " " " " ) ) ) ) ) ) + + + + + + d d d d d d d d d d d d                                                                              * 5 4 4 4 4 4 E E E E E E E E                         	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	                 L$ L$ L$ L$ L$H L$ L$ L$^*9 9 9 9 9 9rz   