
    i                     L    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 r	S r
S rg)    N)download)build_indexc                 ^    [        U R                  S5      5      n[        SU5      nUSL d   eg)zSTest that download works properly when the parent folder of the download_dir existsanother_dirmwa_ppdbTNstrjoinpathr   tmp_pathdownload_dirdownload_statuss      X/home/james-whalen/.local/lib/python3.13/site-packages/nltk/test/unit/test_downloader.py2test_downloader_using_existing_parent_download_dirr   	   s3     x((78Lz<8Od"""    c                 `    [        U R                  SS5      5      n[        SU5      nUSL d   eg)z[Test that download works properly when the parent folder of the download_dir does not existznon-existing-parent-folderzanother-non-existing-folderr   TNr   r   s      r   6test_downloader_using_non_existing_parent_download_dirr      s<     68UVL z<8Od"""r   c           	      ~   SnSn[        U R                  S5      5      n[        XS-   5       H  n[        R                  R                  S5       n[        SU5      nUSL d   eXA:X  aj  [        R                  R                  S[        R                  R                  SS	5      -  5      nUR                  S   R                  UR                  :X  d   eOMXB:X  aH  [        R                  R                  S
5      nUR                  S   R                  UR                  :X  d   eSSS5        M     g! , (       d  f       GM  = f)zOTest that a second download correctly triggers the 'already up-to-date' messager      test_repeat_downloadzbuiltins.print	stopwordsTz[nltk_data]   Unzipping %s.corporazstopwords.zipz6[nltk_data]   Package stopwords is already up-to-date!N)r	   r
   rangeunittestmockpatchr   callospathjoincall_args_listargs)r   first_downloadsecond_downloadr   i
print_mockr   expected_second_calls           r   test_downloader_redownloadr(      s    NOx(()?@AL>Q#67]]  !12j&{LAO"d***"'/}}'9'91ggll9o>?($ "00388<P<U<UUUU%'/}}'9'9L($ "00388<P<U<UUUU 32 822s   CD,,
D<	c                 z   [        U R                  S5      5      nSn[        R                  R	                  X 5      n[        R
                  " USS9  [        R                  R	                  X2 S35      n[        US5       nUR                  SU S35        S	S	S	5        [        R                  R	                  X2 5      n[        R                  " US
U[        R                  R                  U5      S9  [        [        R                  R                  U5      SS9nUS   S   nUR                  S5      S:X  d   eUR                  S5      n	[        U	[         5      (       d   e[        U	5      S:  d   eUR                  S5      n
[        U
[         5      (       d   e[        U
5      S:  d   eg	! , (       d  f       GN= f)z(Test building index with both checksums.packagestest_packageT)exist_okz.xmlwz<package id="zF" name="A Test Package" webpage="http://www.somefake.url/" unzip="1"/>Nzip)	base_nameformatroot_dirbase_dirzhttps://someurl)rootbase_urlr   idchecksum   sha256_checksum)r	   r
   r   r   r    makedirsopenwriteshutilmake_archivebasenamer   dirnameget
isinstancelen)r   test_pkg_dirtest_pkg_nametest_pkg_pathtest_xml_pathfizip_path	xml_indexpackage_elementmd5_checksumr8   s              r   test_build_indexrL   4   s    x((45L"MGGLLBMKK-GGLL/0FGM	mS	!R
M? + 	
 
" ww||M_>H
!!-0	 WW__\*5FI  l1oOt$666"&&z2LlC((((|q   %))*;<Oos++++!###/ 
"	!s    F++
F:)r   r<   unittest.mockr   nltkr   nltk.downloaderr   r   r   r(   rL    r   r   <module>rQ      s)    	    '##V2$r   