§
    íóÉjR
  ã                   óÊ   — d dl Z d dlZd dlZd dlmZ  ej        dd¬¦  «        d„ ¦   «         Z ej        d¬¦  «        d„ ¦   «         Z ej        d	d¬¦  «        d
„ ¦   «         ZdS )é    N)ÚCorpusReaderÚsessionT)ÚscopeÚautousec              #   ó2  K  — ddl m} ddlm} t          j                             t          |                      ¦   «         ¦  «        ¦  «        }d„ |j        D ¦   «         }||vr(|j         	                    |¦  «         d|_
        d|_        d„ t          j                             dd¦  «                             t          j        ¦  «        D ¦   «         }||vr>t          j                             g |¢|‘¦  «        t          j        d<   d|_
        d|_        dV — dS )aI  Authorize pytest's private session temp base for the whole test tree.

    Under the pathsec sandbox a data/corpus root must resolve inside an allowed
    NLTK data root. pathsec trusts a *private* per-user temp dir (macOS ``$TMPDIR``,
    Windows ``%TEMP%``) but not a *shared, world-writable* one (Linux ``/tmp``,
    mode ``1777``) -- a local attacker could plant files there (CWE-377/378).
    pytest's own session base ``<tmp>/pytest-of-<user>/...`` is private, so
    authorizing exactly that base keeps the suite green everywhere without
    trusting all of ``/tmp``.

    This lives in ``nltk/test/conftest.py`` (not only ``unit/``) so it also covers
    tests directly under ``nltk/test/`` and the ``--doctest-modules`` run. It is
    session-scoped so it runs before module-/session-scoped fixtures, and exports
    the base via ``NLTK_DATA`` as well so ``multiprocessing`` *spawn* children
    (used by several ReDoS / "does not hang" tests) -- which inherit ``os.environ``
    but not ``nltk.data.path`` edits -- trust the same base. Test-only; no
    production behavior changes.
    r   N)Úpathsecc                 ó�   — g | ]C}t          |t          ¦  «        ¯t          j                             t          |¦  «        ¦  «        ‘ŒDS © )Ú
isinstanceÚstrÚosÚpathÚrealpath©Ú.0Úps     úu/home/lighthouse/badge-speaker-benchmark/.benchmark-venv-community/lib/python3.11/site-packages/nltk/test/conftest.pyú
<listcomp>z._authorize_pytest_basetemp.<locals>.<listcomp>!   s>   € ÐUÐUÐU¨!Å*ÈQÕPSÑBTÔBTÐU�RŒW×Ò�c !™fœfÑ%Ô%ÐUÐUÐUó    c                 ó   — g | ]}|¯|‘ŒS r
   r
   r   s     r   r   z._authorize_pytest_basetemp.<locals>.<listcomp>'   s   € ÐSÐSÐS�qÐQRÐS�ÐSÐSÐSr   Ú	NLTK_DATAÚ )Ú	nltk.dataÚdataÚnltkr   r   r   r   r   ÚgetbasetempÚappendÚ_ALLOWED_ROOTS_CACHEÚ_LAST_DATA_PATHSÚenvironÚgetÚsplitÚpathsepÚjoin)Útmp_path_factoryÚ
_nltk_datar   ÚbaseÚknownÚ	env_partss         r   Ú_authorize_pytest_basetempr*   	   s  è è € ð( #Ð"Ð"Ð"Ð"Ð"ØÐÐÐÐÐåŒ7×Ò�CÐ 0× <Ò <Ñ >Ô >Ñ?Ô?Ñ@Ô@€DØUÐU¨z¬ÐUÑUÔU€EØ�5ÐÐØŒ×Ò˜tÑ$Ô$Ð$Ø'+ˆÔ$Ø#'ˆÔ àSÐS�BœJŸNšN¨;¸Ñ;Ô;×AÒAÅ"Ä*ÑMÔMÐSÑSÔS€IØ�9ÐÐÝ"$¤*§/¢/Ð2D°IÐ2D¸tÐ2DÑ"EÔ"E�Œ
�;ÑØ'+ˆÔ$Ø#'ˆÔ Ø	€E€E€E€E€Er   )r   c                 ó¢   — 	 ddl m} | j                             |d¦  «         | j                             |d¦  «         dS # t          $ r Y dS w xY w)z(Disable matplotlib plotting in test coder   NÚgcaÚshow)Úmatplotlib.pyplotÚpyplotÚpatchÚobjectÚImportError)ÚmockerÚplts     r   Ú	mock_plotr5   /   sq   € ðØ'Ð'Ð'Ð'Ð'Ð'àŒ×Ò˜C Ñ'Ô'Ð'ØŒ×Ò˜C Ñ(Ô(Ð(Ð(Ð(øÝð ð ð Øˆˆðøøøs   ‚<A  Á 
AÁAÚmodulec               #   óæ   K  — dV — ddl } t          | j        ¦  «        D ]Q}t          | j        |d¦  «        }t	          |t
          ¦  «        r$t          |d¦  «        r|                     ¦   «          ŒRdS )zc
    After each test session ends (either doctest or unit test),
    unload any loaded corpora
    Nr   Ú_unload)Únltk.corpusÚdirÚcorpusÚgetattrr   r   Úhasattrr8   )r   ÚnameÚobjs      r   Úteardown_loaded_corporar@   <   s„   è è € ð 
€E€E€EàÐÐÐå�D”KÑ Ô ð ð ˆÝ�d”k 4¨Ñ.Ô.ˆÝ�c�<Ñ(Ô(ð 	­W°S¸)Ñ-DÔ-Dð 	Ø�KŠK‰MŒMˆMøðð r   )	r   ÚsysÚpytestÚnltk.corpus.readerr   Úfixturer*   r5   r@   r
   r   r   ú<module>rE      sÂ   ðØ 	€	€	€	Ø 
€
€
€
à €€€à +Ð +Ð +Ð +Ð +Ð +ð €„�i¨Ð.Ñ.Ô.ð"
ð "
ñ /Ô.ð"
ðJ €„˜ÐÑÔð	ð 	ñ Ôð	ð €„�h¨Ð-Ñ-Ô-ðð ñ .Ô-ðð ð r   