
    /hh>                         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  S SKJ	r	  S r
 " S S\R                  5      r " S S\R                  5      r\S	:X  a  \R                  " 5         gg)
    N)support)	os_helperc                 <   [         R                  " X5        [        US5       n[        UR	                  S5      5      nUS   S-   S-  US'   UR                  S5        UR                  U5        SSS5        [         R                  " X5        g! , (       d  f       N%= f)zAcreate a file with the same size and mtime but different content.zr+b   r      N)shutilcopy2open	bytearrayreadseekwritecopystat)template_pathnew_pathf	next_chars       :/opt/python-3.13.8/usr/lib/python3.13/test/test_filecmp.py_create_file_shallow_equalr      sv    
LL)	h	!affQi(	!!q(C/	!	q				 

 OOM, 
	s   AB
Bc                   2    \ rS rSrS rS rS rS rS rSr	g)	FileCompareTestCase   c                    [         R                  U l        [         R                  S-   U l        [         R                  S-   U l        [         R                  S-   U l        SnU R                  U R                  U R                  4 H(  n[        USSS9 nUR                  U5        S S S 5        M*     [        U R                  SSS9 nUR                  S	5        S S S 5        U R                  U R                  4 H$  n[        R                  " U R                  U5        M&     [        U R                  U R
                  5        [        R                  " 5       U l        g ! , (       d  f       M  = f! , (       d  f       N= f)
Nz-samez-diffz-same-shallowContents of file go here.
wutf-8encodingza+zAn extra line.
)r   TESTFNname	name_same	name_diffname_same_shallowr
   r   r   r   r   tempfile
gettempdirdir)selfdatar    outputs       r   setUpFileCompareTestCase.setUp   s   $$	"))G3"))G3!*!1!1O!C,YY?DdC'2fT" 32 @ $..$9VLL+, : ^^T^^4DOODIIt, 5 	#499d.D.DE&&( 32 :9s   EE+
E(	+
E9c                    [         R                  " U R                  5        [         R                  " U R                  5        [         R                  " U R                  5        [         R                  " U R
                  5        g N)osunlinkr    r!   r"   r#   r'   s    r   tearDownFileCompareTestCase.tearDown-   sD    
		$))
		$..!
		$..!
		$(()    c                 N   U R                  [        R                  " U R                  U R                  5      S5        U R                  [        R                  " U R                  U R                  SS9S5        U R                  [        R                  " U R                  U R                  5      S5        U R                  [        R                  " U R                  U R                  SS9S5        U R                  [        R                  " U R                  U R
                  5      S5        g )NzComparing file to itself failsFshallowz&Comparing file to identical file failsz2Shallow identical files should be considered equal)
assertTruefilecmpcmpr    r!   r#   r0   s    r   test_matching!FileCompareTestCase.test_matching3   s    DIItyy98	:DIItyy%H8	:DIIt~~>@	BDIIt~~uM@	BDIIt/E/EFL	Nr3   c                 d   U R                  [        R                  " U R                  U R                  5      S5        U R                  [        R                  " U R                  U R
                  5      S5        U R                  [        R                  " U R                  U R                  SS9S5        g )Nz!Mismatched files compare as equalz#File and directory compare as equalFr5   z;Mismatched file to shallow identical file compares as equal)assertFalser8   r9   r    r"   r&   r#   r0   s    r   test_different"FileCompareTestCase.test_different?   s|    TYY?7	9TYY99	;TYY0F0F-24U	Wr3   c                 .   [         R                  " U R                  U R                  SS9n[         R                  " U R                  U R                  SS9n[         R
                  " 5         U R                  [        [         R                  5      S:H  S5        g )NFr5   r   z+Cache not cleared after calling clear_cache)	r8   r9   r    r!   r"   clear_cacher7   len_cache)r'   first_comparesecond_compares      r   test_cache_clear$FileCompareTestCase.test_cache_clearH   sb    DIIt~~uM TYYNGNN+q0E	Gr3   )r&   r    r"   r!   r#   N)
__name__
__module____qualname____firstlineno__r*   r1   r:   r>   rF   __static_attributes__ r3   r   r   r      s    )(*
NWGr3   r   c                       \ 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g)DirCompareTestCaseO   c                    [         R                  " 5       n[        R                  R	                  US5      U l        [        R                  R	                  US5      U l        [        R                  R	                  US5      U l        [        R                  R	                  US5      U l        [        R                  R	                  US5      U l	        [        R                  R	                  U R                  S5      U l
        [        R                  R                  S5      [        R                  R                  S5      :H  U l        S	n[        R                  " U R
                  S
5        [        R                  " U R
                  5        [        R                  R	                  U R
                  S5      n[        R                  " U5        [        R                  R	                  U R
                  S5      n[!        USSS9 nUR#                  U5        S S S 5        U R                  U R                  U R                  U R                  4 H  n[        R                  " US
5        [        R                  " U5        [        R                  R	                  US5      n[        R                  " U5        U R                  (       a  X`R                  L a  SnOSn[        R                  R	                  Xg5      nX`R                  L a  [%        XH5        M  [        R&                  " XH5        M     [!        [        R                  R	                  U R                  S5      SSS9 nUR#                  S5        S S S 5        [!        [        R                  R	                  U R                  S5      SSS9 nUR#                  S5        S S S 5        g ! , (       d  f       GN= f! , (       d  f       Nn= f! , (       d  f       g = f)Nr&   zdir-samezdir-diffzdir-diff-filezdir-same-shallow.hgAar   Tsubdirfiler   r   r   FiLefile2zAn extra file.
zDifferent contents.
)r$   r%   r.   pathjoinr&   dir_samedir_diffdir_diff_filedir_same_shallowdir_ignorednormcasecaseinsensitiver   rmtreemkdirr
   r   r   r	   )	r'   tmpdirr(   subdir_pathdir_file_pathr)   r&   fn	file_paths	            r   r*   DirCompareTestCase.setUpP   s   $$&77<<.VZ8VZ8WW\\&/B "V5G H 77<<u=!ww//48H8H8MM,dhh%
ggll488X6
TXXv6-w76LL 8 MM4#8#8MM4#5#57CMM#t$HHSM'',,sH5KHH[!##}}(<S-I+++*=D]6!7$ "'',,t}}g6gNRXLL+, O "'',,t117;S7SW]LL01 TS3 87* ON TSs$   :N;O O;
O

O
O,c                     U R                   U R                  U R                  U R                  U R                  4 H  n[
        R                  " U5        M     g r-   )r&   r[   r\   r^   r]   r   rb   )r'   r&   s     r   r1   DirCompareTestCase.tearDown   s>    HHdmmT]]))4+=+=?CMM#?r3   c                 D    U R                  S[        R                  5        g )NrR   )assertInr8   DEFAULT_IGNORESr0   s    r   test_default_ignores'DirCompareTestCase.test_default_ignores   s    eW445r3   c           	         U R                  [        R                  " U R                  U R                  S/5      S// / 4:H  S5        U R                  [        R                  " U R                  U R                  S/5      S// / 4:H  S5        U R                  [        R                  " U R                  U R                  S/SS9S// / 4:H  S5        U R                  [        R                  " U R                  U R                  S/SS9S5        U R                  [        R                  " U R                  U R                  SS/5      S/S// 4:H  S5        g )NrV   z#Comparing directory to itself failsz!Comparing directory to same failsFr5   rX   z&Comparing mismatched directories fails)r7   r8   cmpfilesr&   r[   r=   r]   r0   s    r   test_cmpfiles DirCompareTestCase.test_cmpfiles   s:   ((488fXF 2r*+=	? 	((4==6(K 2r*+;	=
 	((488fX168 2r*+ >	? 	((4==6(168;	= 	))$((D4F4F&,g%68Xy"-. =	>r3   c           	      ^   S[         S-   S4SSS-  S44 H  u  pU R                  U R                  U R                  4 HW  nU R	                  SU 3US	9   [
        R                  " U R                  X1/5      nU R                  U/ / U/45        S S S 5        MY     M     g ! , (       d  f       Mo  = f)
N) zNUL bytes filenamerv   z filename with embedded NUL bytes)u	   .py'surrogate codes (MUSICAL SYMBOL G CLEF)rT   @B zvery long filenamez
cmpfiles: )	other_dir)__file__r&   r[   r\   subTestr8   rr   assertTupleEqual)r'   rV   descry   ress        r   test_cmpfiles_invalid_names.DirCompareTestCase.test_cmpfiles_invalid_names   s     + BCJ9_23	
JD #hht}}E	\\Jtf"5\K!**488YGC))#B/?@ LK F
 LKs   9B
B,c           	         SS[         R                   S3S4SSS-  S44 H  u  p[        R                  " U R                  U5      n[        R                  " XR                  5      nS	 H  nU R                  S
U 3US9   U R                  [        [        45         [        X55        S S S 5        S S S 5        U R                  SU 3US9   U R                  [        [        45         [        XE5        S S S 5        S S S 5        M     M     g ! , (       d  f       Nj= f! , (       d  f       Ns= f! , (       d  f       NA= f! , (       d  f       M  = f)N)rv   zNUL bytes dirnameTopzMid zdirname with embedded NUL bytes)u   rw   rT   rx   zvery long dirname)	left_list
right_list	left_only
right_onlycommonzdircmp(ok, bad): )targetzdircmp(bad, ok): )
r.   sepr8   dircmpr&   r{   assertRaisesOSError
ValueErrorgetattr)r'   bad_dirr}   d1d2r   s         r   test_dircmp_invalid_names,DirCompareTestCase.test_dircmp_invalid_names   s   )266('"$EFG9_12	
MG '2B2B
 \\$5dV"<V\L**GZ+@A+ B M \\$5dV"<V\L**GZ+@A+ B ML
 BA ML BA MLsH   >DD
	&D	D=%D,	1D=

DD
D),
D:6D==
Ec                 L    U R                  [        U5      [        U5      5        g)z0Assert that two lists are equal, up to ordering.N)assertEqualsorted)r'   actualexpecteds      r   _assert_lists DirCompareTestCase._assert_lists   s    )9:r3   c                 B    U R                  5         U R                  SS9  g NFr5   )$_assert_dircmp_identical_directoriesr0   s    r   !test_dircmp_identical_directories4DirCompareTestCase.test_dircmp_identical_directories       11311%1@r3   c                 B    U R                  5         U R                  SS9  g r   )_assert_dircmp_different_filer0   s    r   test_dircmp_different_file-DirCompareTestCase.test_dircmp_different_file   s    **,**5*9r3   c                 B    U R                  5         U R                  SS9  g r   )$_assert_dircmp_different_directoriesr0   s    r   !test_dircmp_different_directories4DirCompareTestCase.test_dircmp_different_directories   r   r3   c                    U R                   U R                  p2[        R                  " X#40 UD6nU R	                  UR
                  U5        U R	                  UR                  U5        U R                  (       a=  U R                  UR                  SS/5        U R                  UR                  SS/5        O<U R                  UR                  SS/5        U R                  UR                  SS/5        U R                  UR                  SS/5        U R                  UR                  S/5        U R	                  UR                  / 5        U R	                  UR                  / 5        U R	                  UR                  S/5        U R	                  UR                   / 5        SR#                  U R                   U R                  5      SS/nU R%                  UR&                  U5        g )NrV   rU   rW   
diff {} {}Identical files : ['file']"Common subdirectories : ['subdir'])r&   r[   r8   r   r   leftrightra   r   r   r   r   common_dirsr   r   
same_files
diff_filesformat_assert_reportreportr'   optionsleft_dir	right_dirdexpected_reports         r   r   7DirCompareTestCase._assert_dircmp_identical_directories   su   "hh)NN8:':*),q{{VX,>?q||fh-?@q{{VX,>?q||fh-?@188fh%781==8*5b)r*x0r*$--8(0

 	AHHo6r3   c                    U R                   U R                  p2[        R                  " X#40 UD6nU R	                  UR
                  U5        U R	                  UR                  U5        U R                  UR                  SS/5        U R                  UR                  / SQ5        U R                  UR                  SS/5        U R                  UR                  S/5        U R	                  UR                  / 5        U R	                  UR                  S/5        U R	                  UR                  S/5        U R	                  UR                  / 5        SR!                  U R                   U R                  5      SR!                  U R                  5      SS/nU R#                  UR$                  U5        U R                  U R                   p2[        R                  " X#40 UD6nU R	                  UR
                  U5        U R	                  UR                  U5        U R                  UR                  / SQ5        U R                  UR                  SS/5        U R                  UR                  SS/5        U R	                  UR                  S/5        U R	                  UR                  / 5        U R	                  UR                  S/5        U R	                  UR                  / 5        SR!                  U R                  U R                   5      SR!                  U R                  5      SS/nU R#                  UR$                  U5        g )	NrV   rU   )rV   rX   rU   rX   r   zOnly in {} : ['file2']r   r   )r&   r\   r8   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s         r   r   7DirCompareTestCase._assert_dircmp_different_directories   s~   "hh)NN8:':*),1;;(:;1<<)DE188fh%781==8*5b)y1x0r*$--8$++DMM:(0	
 	AHHo6 #mmTXX)NN8:':*),1;;(CD1<<&();<188fh%78wi0r*x0r*txx8$++DMM:(0	
 	AHHo6r3   c                 \   [         R                  " U R                  U R                  40 UD6nU R	                  UR
                  S/5        U R	                  UR                  S/5        SR                  U R                  U R                  5      SSS/nU R                  UR                  U5        g )NrV   rX   r   r   zDiffering files : ['file2']r   )
r8   r   r\   r]   r   r   r   r   r   r   )r'   r   r   r   s       r   r   0DirCompareTestCase._assert_dircmp_different_file  s    NN4==$*<*<HHx0y1t/A/AB()0	
 	AHHo6r3   c                 T   [         R                  " U R                  U R                  SS9nU R	                  UR
                  / 5        U R	                  UR                  S/5        SR                  U R                  U R                  5      SS/nU R                  UR                  U5        g )NFr5   rV   r   zDiffering files : ['file']r   
r8   r   r&   r^   r   r   r   r   r   r   r'   r   r   s      r   %test_dircmp_no_shallow_different_file8DirCompareTestCase.test_dircmp_no_shallow_different_file"  s    NN488T%:%:EJr*x0$*?*?@(0

 	AHHo6r3   c                 V   [         R                  " U R                  U R                  5      nU R	                  UR
                  S/5        U R	                  UR                  / 5        SR                  U R                  U R                  5      SS/nU R                  UR                  U5        g )NrV   r   r   r   r   r   s      r   test_dircmp_shallow_same_file0DirCompareTestCase.test_dircmp_shallow_same_file.  s    NN488T%:%:;x0r*$*?*?@(0

 	AHHo6r3   c           
      |   U R                  [        [        R                  " S5      5         [        R
                  " U R                  U R                  S S S5        S S S 5        U R                  [        R
                  " U R                  U R                  S S SS9[        R
                  5        g ! , (       d  f       NY= f)NzIdircmp.__init__() takes from 3 to 5 positional arguments but 6 were givenTr5   )	assertRaisesRegex	TypeErrorreescaper8   r   r&   r[   assertIsInstancer0   s    r   #test_dircmp_shallow_is_keyword_only6DirCompareTestCase.test_dircmp_shallow_is_keyword_only:  s    ##IIab
 NN488T]]D$E	

 	NN488T]]D$MNN	

 
s   /B--
B;c                     " S S[         R                  5      nU" U R                  U R                  5      nUR                  nU R                  [        UR                  5       5      S/5        US   nU R                  [        U5      U5        g)z/Check that dircmp.subdirs respects subclassing.c                       \ rS rSrSrg)=DirCompareTestCase.test_dircmp_subdirs_type.<locals>.MyDirCmpiG  rM   N)rH   rI   rJ   rK   rL   rM   r3   r   MyDirCmpr   G  s    r3   r   rU   N)	r8   r   r&   r\   subdirsr   listkeystype)r'   r   r   sub_dirssub_dcmps        r   test_dircmp_subdirs_type+DirCompareTestCase.test_dircmp_subdirs_typeE  sj    	w~~ 	TXXt}}-99hmmo.
;H%h2r3   c                    U R                   U R                  p![        R                  " X5      n[        R
                  R                  US5      n[        R
                  R                  US5      nSR                  U R                   U R                  5      SSSSR                  XE5      /nU R                  UR                  U5        g NrU   r   r   r    )
r&   r[   r8   r   r.   rY   rZ   r   r   report_partial_closurer'   r   r   r   left_subdirright_subdirr   s          r   test_report_partial_closure.DirCompareTestCase.test_report_partial_closureO  s    "hh)NN8/ggll8X6ww||Ix8$--8(0:
 	A44oFr3   c                    U R                   U R                  p![        R                  " X5      n[        R
                  R                  US5      n[        R
                  R                  US5      nSR                  U R                   U R                  5      SSSSR                  XE5      /nU R                  UR                  U5        g r   )
r&   r[   r8   r   r.   rY   rZ   r   r   report_full_closurer   s          r   test_report_full_closure+DirCompareTestCase.test_report_full_closure]  s    "hh)NN8/ggll8X6ww||Ix8$--8(0:
 	A11?Cr3   c                     [         R                  " 5        nU" 5         UR                  5       R                  5       R	                  S5      nU R                  XB5        S S S 5        g ! , (       d  f       g = f)N
)r   captured_stdoutgetvaluestripsplitr   )r'   dircmp_reportexpected_report_linesstdoutreport_liness        r   r   !DirCompareTestCase._assert_reportk  sO    $$&&O!??,224::4@L\A '&&s   AA%%
A3)ra   r&   r\   r]   r_   r[   r^   N)rH   rI   rJ   rK   r*   r1   ro   rs   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rL   rM   r3   r   rO   rO   O   sn    .2b
6>,A,*;A:A72(7V7
7
7	
3GDBr3   rO   __main__)r8   r.   r   r   r$   unittesttestr   test.supportr   r   TestCaser   rO   rH   mainrM   r3   r   <module>r      sg     	 	     "
I5G(++ 5Gn`B** `BF	 zMMO r3   