
    [j3                       d Z ddlmZ ddlZddlmZ ddlmZ ddlZddl	Z	ddl
mZ ddlZddlmZ ddlZddlZddlmZ dd	lmZ dd
lmZ ddl
mZ ddl
mZ ddl
mZ ddl
mZ ddl
mZ ddlmZ ddlmZ ddlmZ ddlmZ ddl m!Z! ddl"m#Z# ddl$m%Z% ddl$m&Z& ddl'm(Z( ddl)m*Z* ddl+m,Z, ddl-m.Z.  e.e/e0e1f                              Z2ed         Z3eej4         G d d                                  Z5d>d"Z6d?d&Z7d@d)Z8 e%d*+          dAd.            Z9dBd1Z:e%dCd4            Z;dDd7Z< ed8d89          dEd=            Z=dS )Fz>Support for providing temporary directories to test functions.    )annotationsN)	Generator)	ExitStack)Path)rmtree)Any)final)Literal   )cleanup_dead_symlinks)LOCK_TIMEOUT)make_numbered_dir)make_numbered_dir_with_cleanup)rm_rf)get_user_id)Config)ExitCode)hookimpl)Parser)check_ispytest)fixture)FixtureRequest)MonkeyPatch)Item)
TestReport)StashKeyallfailednonec                      e Zd ZU dZded<   ded<   ded<   ded<   d	ed
<   	 d"ddd#dZeddd$d            Zd%dZd&d'd Z	d(d!Z
dS ))TempPathFactoryzFactory for temporary directories under the common base temp directory,
    as discussed at :ref:`temporary directory location and retention`.
    Path | None_given_basetempr   _trace	_basetempint_retention_countRetentionType_retention_policyNF	_ispytestgiven_basetempretention_countretention_policybasetempr,   boolreturnNonec                  t          |           |d | _        n>t          t          j                            t          |                              | _        || _        || _        || _	        || _
        t                      | _        d S N)r   r$   r   ospathabspathstrr%   r(   r*   r&   r   _exit_stack)selfr-   r.   r/   tracer0   r,   s          R/var/www/app.qaans.com/backend/venv/lib/python3.11/site-packages/_pytest/tmpdir.py__init__zTempPathFactory.__init__9   s}     	y!!!!#'D  
 $(N8K8K(L(L#M#MD  /!1! %;;    configr   c               R   t          |           t          |                    d                    }|dk     rt          d| d          |                    d          }|dvrt          d| d           | |j        j        |j                            d          ||d	
          S )zTCreate a factory according to pytest configuration.

        :meta private:
        tmp_path_retention_countr   z6tmp_path_retention_count must be >= 0. Current input: .tmp_path_retention_policyr   zKtmp_path_retention_policy must be either all, failed, none. Current input: tmpdirT)r-   r<   r.   r/   r,   )r   r'   getini
ValueErroroptionr0   r<   get)clsr@   r,   countpolicys        r=   from_configzTempPathFactory.from_configS   s     	y!!!FMM"<==>>199QQQQ   :;;222g^dggg   s!=1,""8,,!#
 
 
 	
r?   basenamer9   c                    t           j                            |          }|                                 |z                                  j        |                                 k    rt          | d          |S )Nz& is not a normalized and relative path)r6   r7   normpathgetbasetempresolveparentrG   )r;   rN   s     r=   _ensure_relative_to_basetempz,TempPathFactory._ensure_relative_to_basetemps   sj    7##H--)2244;t?O?O?Q?QQQPPPQQQr?   Tnumberedr   c                $   |                      |          }|s>|                                                     |          }|                    d           n:t	          |                                 |d          }|                     d|           |S )a  Create a new temporary directory managed by the factory.

        :param basename:
            Directory base name, must be a relative path.

        :param numbered:
            If ``True``, ensure the directory is unique by adding a numbered
            suffix greater than any existing one: ``basename="foo-"`` and ``numbered=True``
            means that this function will create directories named ``"foo-0"``,
            ``"foo-1"``, ``"foo-2"`` and so on.

        :returns:
            The path to the new directory.
          mode)rootprefixrY   mktemp)rT   rQ   joinpathmkdirr   r%   )r;   rN   rU   ps       r=   r\   zTempPathFactory.mktempy   s     44X>> 	%  ""++H55AGGG!t'7'7'9'9(QVWWWAKK!$$$r?   c                   | j         | j         S | j        V| j        }|                                rt          |           |                    d           |                                }n*t          j                            d          }t          |pt          j                                                              }t                      pd}|                    d|           }	 |                    dd           n<# t          $ r/ |                    d	          }|                    dd           Y nw xY wt                      }|t          j        t          j        v rd
nd}|                    |          }t!          j        |j                  rt          d| d          |j        |k    rt          d| d          |j        dz  dk    r;t          j        t          j        v rd
nd}	|                    |j        dz  |	           | j        }
| j        dk    rd}
t1          d||
t2          d| j        j                  }t9          j        | j        j                   | j                            t8          j        | j        j                   |
J |            || _         |                      d|           |S )zReturn the base temporary directory, creating it if needed.

        :returns:
            The base temporary directory.
        NrW   rX   PYTEST_DEBUG_TEMPROOTunknownz
pytest-of-T)rY   exist_okzpytest-of-unknownF)follow_symlinkszThe temporary directory z, is a symbolic link. Fix this and try again.z: is not owned by the current user. Fix this and try again.?   r   ir    zpytest-)r[   rZ   keeplock_timeoutrY   registerznew basetemp)!r&   r$   existsr   r^   rR   r6   environrI   r   tempfile
gettempdirget_userr]   OSErrorr   statsupports_follow_symlinksS_ISLNKst_modest_uidchmodr(   r*   r   r   r:   callbackatexitrh   close
unregisterr%   )r;   r0   from_envtemprootuserrootdiruidstat_follow_symlinksrootdir_statchmod_follow_symlinksrf   s              r=   rQ   zTempPathFactory.getbasetemp   s    >%>!++H    hNNN&&&''))HHz~~&=>>HH=(;(=(=>>FFHHH::*D ''(;T(;(;<<G9548888 9 9 9"++,?@@54888889" --CW(CCCEE %  '||<P|QQ< 455 !27 2 2 2    &#--!27 2 2 2   !(50Q66!#R-H!H!Hd * MM$,v5(= "    (D%//5 ))2  H OD,2333%%f&79I9OPPP##X###!NH---s   (D   6D98D9r5   )r-   r#   r.   r'   r/   r)   r0   r#   r,   r1   r2   r3   )r@   r   r,   r1   r2   r"   )rN   r9   r2   r9   )T)rN   r9   rU   r1   r2   r   )r2   r   )__name__
__module____qualname____doc____annotations__r>   classmethodrM   rT   r\   rQ    r?   r=   r"   r"   +   s           !   KKK$$$$ !%'  ' ' ' ' ' '4 
  	
 
 
 
 
 [
>       0T T T T T Tr?   r"   r2   
str | Nonec                 p    	 ddl } |                                 S # t          t          t          f$ r Y dS w xY w)zlReturn the current user name, or None if getuser() does not work
    in the current environment (see #1010).r   N)getpassgetuserImportErrorrn   KeyError)r   s    r=   rm   rm      sI       (+   tts    55r@   r   r3   c                    t                      }|                     |j                   t                              | d          }|                    | d|d           dS )a  Create a TempPathFactory and attach it to the config object.

    This is to comply with existing plugins which expect the handler to be
    available at pytest_configure time, but ideally should be moved entirely
    to the tmp_path_factory session fixture.
    Tr+   _tmp_path_factoryF)raisingN)r   add_cleanupundor"   rM   setattr)r@   mpr   s      r=   pytest_configurer      s^     
B
rw'33Fd3KKJJv*,=uJMMMMMr?   parserr   c                j    |                      dddd           |                      dddd	           d S )
NrB   zfHow many sessions should we keep the `tmp_path` directories, according to `tmp_path_retention_policy`.3string)helpdefaulttyperD   zvControls which directories created by the `tmp_path` fixture are kept around, based on test outcome. (all/failed/none)r   )r   r   r   )addini)r   s    r=   pytest_addoptionr     s^    
MM"u     MM#      r?   session)scoperequestr   c                    | j         j        S )zGReturn a :class:`pytest.TempPathFactory` instance for the test session.)r@   r   )r   s    r=   tmp_path_factoryr     s     >++r?   factoryr   c                    | j         j        }t          j        dd|          }d}|d |         }|                    |d          S )Nz[\W]_   T)rU   )nodenameresubr\   )r   r   r   MAXVALs       r=   _mk_tmpr     sG    <D6'3%%DF=D>>$>...r?   r   Generator[Path]c              #     K   t          | |          }|V  |j        }| j        j        t                   }|dk    r'|                    dd          rt          |d           | j        j        t          = dS )a;  Return a temporary directory (as :class:`pathlib.Path` object)
    which is unique to each test function invocation.
    The temporary directory is created as a subdirectory
    of the base temporary directory, with configurable retention,
    as discussed in :ref:`temporary directory location and retention`.
    r   callTignore_errorsN)r   r*   r   stashtmppath_result_keyrI   r   )r   r   r7   rL   result_dicts        r=   tmp_pathr   "  s       7,--D
JJJ /F,$%78Kkoofd;; 	t4((((-...r?   
exitstatusint | ExitCodec                *   | j         j        }|j        }|dS |j        }|dk    r2|dk    r,|j        %|                                rt          |d           |                                rt          |           |j        	                                 dS )zAfter each session, remove base directory if all the tests passed,
    the policy is "failed", and the basetemp is not specified by a user.
    Nr   r   Tr   )
r@   r   r&   r*   r$   is_dirr   r   r:   rw   )r   r   r   r0   rL   s        r=   pytest_sessionfinishr   ;  s     )0(H)H/Fah,4?? 	1 840000  (h'''  &&(((((r?   T)wrappertryfirstitemr   'Generator[None, TestReport, TestReport]c              #     K   d V }|j         J i }|j        | j                            t          |          |j         <   |S r5   )whenpassedr   
setdefaultr   )r   r   repemptys       r=   pytest_runtest_makereportr   W  sJ       %%C8EADDJ,e44SX>Jr?   )r2   r   )r@   r   r2   r3   )r   r   r2   r3   )r   r   r2   r"   )r   r   r   r"   r2   r   )r   r   r   r"   r2   r   )r   r   )r   r   r2   r   )>r   
__future__r   rv   collections.abcr   
contextlibr   dataclassesr6   pathlibr   r   shutilr   ro   rk   typingr   r	   r
   r   r   r   r   r   _pytest.compatr   _pytest.configr   r   r   _pytest.config.argparsingr   _pytest.deprecatedr   _pytest.fixturesr   r   _pytest.monkeypatchr   _pytest.nodesr   _pytest.reportsr   _pytest.stashr   dictr9   r1   r   r)   	dataclassr"   rm   r   r   r   r   r   r   r   r   r?   r=   <module>r      si   D D " " " " " "  % % % % % %                 				       				                           * * * * * * ! ! ! ! ! ! & & & & & & 3 3 3 3 3 3       & & & & & & ! ! ! ! ! ! # # # # # # # # # # # # , , , , , , - - - - - - $ $ $ $ $ $ + + + + + + + + + + + +       & & & & & & " " " " " " /Xd39o.00 /0 x x x x x x x  xv	 	 	 	
N 
N 
N 
N   $ 	y, , , ,/ / / / 	/ / / 	/0) ) ) )8 
$&&&   '&  r?   