
    )+Ci                         S SK r S SKJr   S SKJrJr  S SKJ	r	   " S S\ R                  5      r " S S\ R                  5      r\S	:X  a  \ R                  " 5         gg! \ a    S SKJrJr   NYf = f)
    N)Path)callpatch)zbar_libraryc                   8    \ rS rSrS rS rS rS rS rS r	Sr
g	)
TestLoad   c                 2   U R                  [        R                  5        [        SSS9R                  5       U l        [        SSS9R                  5       U l        [        SSS9R                  5       U l        [        SSSS/4S	9R                  5       U l        g )
Nzpyzbar.zbar_library.cdllTautospecz pyzbar.zbar_library.find_libraryzpyzbar.zbar_library.platformz#pyzbar.zbar_library._windows_fnames	dll fnamedependency fname)r   return_value)
addCleanupr   stopallstartcdllfind_libraryplatformwindows_fnamesselfs    X/home/james-whalen/.local/lib/python3.13/site-packages/pyzbar/tests/test_zbar_library.pysetUpTestLoad.setUp   s    &&

%' 		 ".

%' 	 *T

%' 	 $1D%(:';<
 %' 	    c                    SU R                   R                  l        [        R                  " 5       nU R                   R                  R                  5         U R                  R                  S5        U R                  R                  R                  U R                  R                  5        U R                  U R                  R                  R                  / 4U5        U R                  SU R                  R                  5        g)z&zbar loaded ok on non-Windows platformNot windowszbarr   N)r   systemr   r   loadassert_called_once_withr   r   LoadLibraryassertEqualr   
call_countr   ress     r   test_found_non_windowsTestLoad.test_found_non_windows   s    ,9)!44611&9		55**	
 	$))//<<bA3GD//::;r   c                 "   SU R                   R                  l        SU R                  l        U R	                  [
        [        R                  5        U R                   R                  R                  5         U R                  R                  S5        g)z&zbar not found on non-Windows platformr   Nr   )	r   r    r   r   assertRaisesImportErrorr   r!   r"   r   s    r   test_not_found_non_windows#TestLoad.test_not_found_non_windows.   sb    ,9))-&+|'8'8944611&9r   c                    SU R                   R                  l        [        R                  " 5       nU R                   R                  R                  5         U R                  R                  R                  [        S5      [        S5      /5        U R                  U R                  R                  R                  U R                  R                  R                  /4U5        g)zzbar found on WindowsWindowsr   r   N)r   r    r   r   r!   r"   r   r#   assert_has_callsr   r$   r&   s     r   test_found_windowsTestLoad.test_found_windows8   s    ,5)!446		..#$0
 	 			%%22&&334 	
r   c                    SU R                   R                  l        [        SS/U R                  R
                  l        [        R                  " 5       nU R                   R                  R                  5         U R                  R
                  R                  [        S5      [        [        [        [        R                  5      R                  R!                  S5      5      5      [        [        [        [        R                  5      R                  R!                  S5      5      5      /5        U R#                  SS/4U5        g)z+zbar found on the second attempt on Windowsr0   zloaded dependencyzloaded zbarr   r   N)r   r    r   OSErrorr   r#   side_effectr   r!   r"   r1   r   strr   __file__parentjoinpathr$   r&   s     r   !test_found_second_attempt_windows*TestLoad.test_found_second_attempt_windowsK   s    ,5)-
		) !446		..#$T,//077@@"   T,//077@@  0
 	 	-*=)>?Er   c           
         SU R                   R                  l        [        U R                  R
                  l        U R                  [        [        R                  5        U R                   R                  R                  5         U R                  R
                  R                  [        S5      [        [        [        [        R                  5      R                   R#                  S5      5      5      /5        g)zzbar not found on Windowsr0   r   N)r   r    r   r5   r   r#   r6   r+   r   r!   r"   r1   r   r7   r   r8   r9   r:   r   s    r   test_not_found_windowsTestLoad.test_not_found_windowsc   s    ,5),3		)'<#4#45446		..#$T,//077@@"  0
 	r   )r   r   r   r   N)__name__
__module____qualname____firstlineno__r   r(   r-   r2   r;   r>   __static_attributes__ r   r   r   r      s!     <:
&F0r   r   c                   &    \ rS rSrS rS rS rSrg)TestWindowsFnamest   c                 |    U R                  [        R                  5        [        SSS9R                  5       U l        g )Nzpyzbar.zbar_library.sysTr   )r   r   r   r   sysr   s    r   r   TestWindowsFnames.setUpu   s*    &2TBHHJr   c                 v    SU R                   l        U R                  SS/4[        R                  " 5       5        g )Nl        zlibzbar-32.dllzlibiconv-2.dllrJ   maxsizer$   r   _windows_fnamesr   s    r   
test_32bitTestWindowsFnames.test_32bity   s4      012((*	
r   c                 v    SU R                   l        U R                  SS/4[        R                  " 5       5        g )Nl       zlibzbar-64.dllzlibiconv.dllrM   r   s    r   
test_64bitTestWindowsFnames.test_64bit   s3    $/0((*	
r   )rJ   N)r@   rA   rB   rC   r   rP   rS   rD   rE   r   r   rG   rG   t   s    K

r   rG   __main__)unittestpathlibr   unittest.mockr   r   r,   mockpyzbarr   TestCaser   rG   r@   mainrE   r   r   <module>r]      so     !)
  cx   cL
)) 
* zMMO E  !  !s   A A.-A.