
    9[geW                       d Z ddlmZ ddlZddl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
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Z(dZ)eejT                   G d d                    Z+ G d d      Z, G d d       Z- G d! d"      Z. G d# d$      Z/d-d%Z0d.d&Z1 ed'(      d/d)       Z2ed0d*       Z3d1d+Z4d2d,Z5y)3z%Implementation of the cache provider.    )annotationsN)Path)final)	Generator)Iterable   )resolve_from_str)rm_rf)CollectReport)nodes)TerminalWriter)Config)ExitCode)hookimpl)Parser)check_ispytest)fixture)FixtureRequest)Session)	Directory)File)
TestReporta.  # pytest cache directory #

This directory contains data from the pytest's cache plugin,
which provides the `--lf` and `--ff` options, as well as the `cache` fixture.

**Do not** commit this to version control.

See [the docs](https://docs.pytest.org/en/stable/how-to/cache.html) for more information.
s   Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by pytest.
# For information about cache directory tags, see:
#	https://bford.info/cachedir/spec.html
c                     e Zd ZU dZ ej
                  d      Zded<    ej
                  d      Zded<   dZ	d	Z
dd
	 	 	 	 	 	 	 ddZedd
dd       Zeddd       Zedd
dd       Zdd
ddZddZddZddZd dZd!dZd"dZy)#Cachez Instance of the `cache` fixture.F)reprr   	_cachedirr   _configdv	_ispytestc               6    t        |       || _        || _        y N)r   r   r   )selfcachedirconfigr!   s       P/var/www/html/bid-api/venv/lib/python3.12/site-packages/_pytest/cacheprovider.py__init__zCache.__init__E   s     	y!!    c                   t        |       | j                  |d      }|j                  d      r#|j                         r| j	                  |d        | ||d      S )zHCreate the Cache instance for a Config.

        :meta private:
        Tr    
cacheclear)r   cache_dir_from_config	getoptionis_dirclear_cache)clsr&   r!   r%   s       r'   
for_configzCache.for_configL   sW     	y!,,Vt,DL)hoo.?OOHO58Vt44r)   c                    t        |       | j                  | j                  fD ]#  }||z  }|j                         st	        |       % y)zfClear the sub-directories used to hold cached directories and values.

        :meta private:
        N)r   _CACHE_PREFIX_DIRS_CACHE_PREFIX_VALUESr.   r
   )r0   r%   r!   prefixr   s        r'   r/   zCache.clear_cacheX   sB     	y!--s/G/GHF6!Axxza Ir)   c               b    t        |       t        | j                  d      | j                        S )zRGet the path to the cache directory for a Config.

        :meta private:
        	cache_dir)r   r	   getinirootpath)r&   r!   s     r'   r,   zCache.cache_dir_from_configd   s&     	y!k :FOOLLr)   c          	         t        |       ddl}ddlm} |j	                   ||r |j
                  di |n|      | j                  j                  d       y)z7Issue a cache warning.

        :meta private:
        r   N)PytestCacheWarning   )
stacklevel )r   warnings_pytest.warning_typesr;   warnformatr   hook)r$   fmtr!   argsr?   r;   s         r'   rA   z
Cache.warnm   sM    
 	y!<Tzszz1D1sCLL 	 	
r)   c                J    | j                          |j                  dd       y )NT)exist_okparents)&_ensure_cache_dir_and_supporting_filesmkdir)r$   paths     r'   _mkdirzCache._mkdir}   s    335

D$
/r)   c                    t        |      }t        |j                        dkD  rt        d      | j                  j                  | j                  |      }| j                  |       |S )a  Return a directory path object with the given name.

        If the directory does not yet exist, it will be created. You can use
        it to manage files to e.g. store/retrieve database dumps across test
        sessions.

        .. versionadded:: 7.0

        :param name:
            Must be a string not containing a ``/`` separator.
            Make sure the name contains your plugin or application
            identifiers to prevent clashes with other cache users.
        r   z.name is not allowed to contain path separators)r   lenparts
ValueErrorr   joinpathr3   rL   )r$   namerK   ress       r'   rJ   zCache.mkdir   sV     Dztzz?QMNNnn%%d&=&=tDC
r)   c                `    | j                   j                  | j                  t        |            S r#   )r   rQ   r4   r   )r$   keys     r'   _getvaluepathzCache._getvaluepath   s#    ~~&&t'@'@$s)LLr)   c                    | j                  |      }	 |j                  dd      5 }t        j                  |      cddd       S # 1 sw Y   yxY w# t        t
        f$ r |cY S w xY w)a  Return the cached value for the given key.

        If no value was yet cached or the value cannot be read, the specified
        default is returned.

        :param key:
            Must be a ``/`` separated value. Usually the first
            name is the name of your plugin or your application.
        :param default:
            The value to return in case of a cache-miss or invalid cache value.
        rUTF-8encodingN)rV   openjsonloadrP   OSError)r$   rU   defaultrK   fs        r'   getz	Cache.get   sZ     !!#&	31Qyy| 211G$ 	N	s-   A A	A A
A A A%$A%c                   | j                  |      }	 | j                  |j                         t        j                  |dd      }	 |j                  d	d
      }|5  |j                  |       ddd       y# t        $ r#}| j	                  d| d| d       Y d}~yd}~ww xY w# 1 sw Y   yxY w# t        $ r#}| j	                  d| d| d       Y d}~yd}~ww xY w)aN  Save value for the given key.

        :param key:
            Must be a ``/`` separated value. Usually the first
            name is the name of your plugin or your application.
        :param value:
            Must be of any combination of basic python types,
            including nested types like lists of dictionaries.
        zcould not create cache path z: Tr    NF   )ensure_asciiindentwrY   rZ   zcache could not write path )	rV   rL   parentr_   rA   r]   dumpsr\   write)r$   rU   valuerK   excdatara   s          r'   setz	Cache.set   s     !!#&	KK$ zz%eA>				#	0A    	II.tfBse<   	   	II-dV2cU;   	s;   A7 B2 B&7	B# BB#&B/2	C;CCc                   | j                   j                         ry| j                   j                  j                  dd       t	        j
                  d| j                   j                        5 }t        |      }t        j                  d      }t        j                  |       |j                  d|z
         t        |j                  d      d	d
      5 }|j                  t               ddd       t        |j                  d      d	d
      5 }|j                  d       ddd       t        |j                  d      d      5 }|j                  t               ddd       	 |j                  | j                          |j                          ddd       y# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   VxY w# t         $ r7}|j"                  t"        j$                  t"        j&                  fvr Y d}~hd}~ww xY w# 1 sw Y   yxY w)z.Create the cache dir and its supporting files.NT)rH   rG   zpytest-cache-files-)r5   dir   i  z	README.mdxrY   rZ   z
.gitignorez%# Created by pytest automatically.
*
zCACHEDIR.TAGxb)r   r.   rh   rJ   tempfileTemporaryDirectoryr   osumaskchmodr\   rQ   rj   README_CONTENTCACHEDIR_TAG_CONTENTrenamer_   errno	ENOTEMPTYEEXIST)r$   newpathrK   rw   ra   es         r'   rI   z,Cache._ensure_cache_dir_and_supporting_files   s   >>  "##D4#@(((%%
 =D HHUOEHHUOJJuu}%dmmK0#HA' IdmmL13IQAB JdmmN3T:a,- ;DNN+" 

K
 
 IHII::
   775??ELL"AA B+
 
s   .A'G?F+%G?F$"#G?F0G?$F<?G?F!	G?$F-	)G?0F9	5G?<	G<-G72G?7G<<G??HN)r%   r   r&   r   r!   boolreturnNone)r&   r   r!   r   r   r   )F)r%   r   r!   r   r   r   )r&   r   r!   r   r   r   )rD   strr!   r   rE   objectr   r   )rK   r   r   r   )rR   r   r   r   )rU   r   r   r   )rU   r   )rU   r   rk   r   r   r   r   r   )__name__
__module____qualname____doc__dataclassesfieldr   __annotations__r   r3   r4   r(   classmethodr1   r/   staticmethodr,   rA   rL   rJ   rV   rb   rn   rI   r>   r)   r'   r   r   7   s     +'k''U3It3'k''U3GV3   DI&,<@	 =B 	5 	5 	 	 CH M M 38 
 0*M&>+r)   r   c                  <    e Zd ZddZ ed      	 	 	 	 dd       Zy)LFPluginCollWrapperc                     || _         d| _        y )NF)lfplugin_collected_at_least_one_failurer$   r   s     r'   r(   zLFPluginCollWrapper.__init__   s     /4,r)   T)wrapperc              #    K   d }t        |t        t        f      r;| j                  j                  dfd}t        |j                  |d      |_        |S t        |t              r|j                  | j                  j                  v r|j                  }| j                  j                  | j                  s`t        fd|D              s|S | j                  j                  j                  j                  t        | j                        d       d| _
        |j                   }|D cg c]G  }|j"                  v s5|j%                  |j                        st        |t&        j(                        r|I c}|d d  |S c c}w w)Nc                     | j                   v S r#   )rK   )nodelf_pathss    r'   sort_keyz@LFPluginCollWrapper.pytest_make_collect_report.<locals>.sort_key  s    yyH,,r)   TrU   reversec              3  :   K   | ]  }|j                   v   y wr#   nodeid).0rr   
lastfaileds     r'   	<genexpr>zALFPluginCollWrapper.pytest_make_collect_report.<locals>.<genexpr>  s     Fv!qxx:5vs   zlfplugin-collskip)r   znodes.Item | nodes.Collectorr   r   )
isinstancer   r   r   _last_failed_pathssortedresultr   rK   r   r   anyr&   pluginmanagerregisterLFPluginCollSkipfilessessionr   
isinitpathr   	Collector)	r$   	collectorrS   r   r   r   rr   r   r   s	          @@r'   pytest_make_collect_reportz.LFPluginCollWrapper.pytest_make_collect_report   sI     i'9!56}}77H-  

CJ> 
3 	4(~~!A!AA!]]55
 ;;FvFF"
MM((66??-dmm<>Q <@D8#++ $#xx:-))!&&1!!U__5 #q	 
s   D'F+AE?7FNr   LFPluginr   r   )r   nodes.Collectorr   z-Generator[None, CollectReport, CollectReport]r   r   r   r(   r   r   r>   r)   r'   r   r      s0    5 d+(+	6+ +r)   r   c                  .    e Zd ZddZe	 	 	 	 dd       Zy)r   c                    || _         y r#   )r   r   s     r'   r(   zLFPluginCollSkipfiles.__init__.  s	     r)   c                    t        |t              rZ|j                  | j                  j                  vr8| j                  xj
                  dz  c_        t        |j                  dd g       S y )Nr   passed)longreprr   )r   r   rK   r   r   _skipped_filesr   r   )r$   r   s     r'   r   z0LFPluginCollSkipfiles.pytest_make_collect_report1  sZ     i&~~T]]%E%EE,,1,$$$hb  r)   Nr   )r   r   r   zCollectReport | Noner   r>   r)   r'   r   r   -  s+    ! 
(
	
 
r)   r   c                  n    e Zd ZdZddZddZddZddZddZ e	dd      	 	 	 	 	 	 dd	       Z
dd
Zy)r   z;Plugin which implements the --lf (run last-failing) option.c                j   | _         d}t        fd|D              | _        j                  sJ j                  j	                  di       | _        d | _        d | _        d| _        j                  d      r;| j                         | _        j                  j                  t        |       d       y y )N)lffailedfirstc              3  @   K   | ]  }j                  |        y wr#   )r-   )r   rU   r&   s     r'   r   z$LFPlugin.__init__.<locals>.<genexpr>E  s     G;C&**3/;s   cache/lastfailedr   r   zlfplugin-collwrapper)r&   r   activecacherb   r   _previously_failed_count_report_statusr   r-   get_last_failed_pathsr   r   r   r   )r$   r&   active_keyss    ` r'   r(   zLFPlugin.__init__B  s    )G;GG|||+1<<+;+;<NPR+S48%*.D!&*&@&@&BD#  ))#D)+A "r)   c                6   | j                   j                  }t               }| j                  D ]E  }||j	                  d      d   z  }|j                  |       |j                  |j                         G |D ch c]  }|j                         s| c}S c c}w )zWReturn a set with all Paths of the previously failed nodeids and
        their parents.z::r   )	r&   r9   rn   r   splitaddupdaterH   exists)r$   r9   r   r   rK   rr   s         r'   r   zLFPlugin.get_last_failed_pathsR  s~     ;;''ooFfll4033DJJtMM$,,' & "06aQXXZ6000s   9BBc                t    | j                   r,| j                  j                         dk\  rd| j                   S y )Nr   zrun-last-failure: )r   r&   get_verbosityr   )r$   s    r'   pytest_report_collectionfinishz'LFPlugin.pytest_report_collectionfinish]  s4    ;;4;;446!;'(;(;'<==r)   c                    |j                   dk(  r|j                  s|j                  r'| j                  j	                  |j
                  d        y |j                  rd| j                  |j
                  <   y y )NcallT)whenr   skippedr   popr   failed)r$   reports     r'   pytest_runtest_logreportz!LFPlugin.pytest_runtest_logreportb  sP    KK6!fmmOOt4]]-1DOOFMM* r)   c                ,   |j                   dv }|rk|j                  | j                  v rR| j                  j                  |j                         | j                  j	                  d |j
                  D               y y d| j                  |j                  <   y )N)r   r   c              3  8   K   | ]  }|j                   d f  yw)TNr   r   items     r'   r   z0LFPlugin.pytest_collectreport.<locals>.<genexpr>m  s     &U}tT':}s   T)outcomer   r   r   r   r   )r$   r   r   s      r'   pytest_collectreportzLFPlugin.pytest_collectreporth  so    #88}}/##FMM2&&&Uv}}&UU 0 .2DOOFMM*r)   Tr   tryfirstc              #    K   d }| j                   s|S | j                  rQg }g }|D ]=  }|j                  | j                  v r|j                  |       -|j                  |       ? t	        |      | _        |sdt	        | j                        fz  | _        n| j                  j                  d      r"||d d  |j                  j                  |       n||z   |d d  | j
                  dk(  rdnd}| j                  j                  d      rdnd	}d
| j
                   d| | | _        | j                  dkD  r9| j                  dk(  rdnd}	| xj                  d| j                   d|	 dz  c_        |S d| _        | j                  j                  d      dk(  r;| xj                  dz  c_        |j                  j                  |d d         g |d d  |S | xj                  dz  c_        |S w)Nz'%d known failures not in selected testsr   )itemsr   failurefailuresr   z first zrerun previous  r   filefilesz
 (skipped )zno previously failed tests, last_failed_no_failuresnonezdeselecting all items.znot deselecting items.)r   r   r   appendrN   r   r   r&   r-   rC   pytest_deselectedr   )
r$   r&   r   rS   previously_failedpreviously_passedr   nounsuffix
files_nouns
             r'   pytest_collection_modifyitemsz&LFPlugin.pytest_collection_modifyitemsq  s     {{J?? " ";;$//1%,,T2%,,T2	 
 -00A,BD)$ 'P(S '# ;;((.0E!HKK118I1J03DDE!H$($A$AQ$FyJ%)[[%:%:=%Ir%d&C&C%DAdVF8T # ""Q&'+':':a'?VW
##D4G4G3H*UV'WW# 
 #AD{{$$%>?6I##'??#--E!H-=a 
 ##'??#
s   G(G*c                   | j                   }|j                  d      st        |d      ry |j                  J |j                  j	                  di       }|| j
                  k7  r'|j                  j                  d| j
                         y y )N	cacheshowworkerinputr   )r&   r-   hasattrr   rb   r   rn   )r$   r   r&   saved_lastfaileds       r'   pytest_sessionfinishzLFPlugin.pytest_sessionfinish  sw    K(GFM,J||'''!<<++,>Ct.LL/A /r)   Nr&   r   r   r   )r   z	set[Path])r   
str | None)r   r   r   r   )r   r   r   r   )r&   r   r   list[nodes.Item]r   Generator[None])r   r   r   r   )r   r   r   r   r(   r   r   r   r   r   r   r   r>   r)   r'   r   r   ?  sX    E 	1
22 dT*11%51	1 +1fBr)   r   c                  J    e Zd ZdZd	dZ edd      d
d       ZddZddZy)NFPluginz8Plugin which implements the --nf (run new-first) option.c                    || _         |j                  j                  | _        |j                  J t        |j                  j                  dg             | _        y )Ncache/nodeids)r&   optionnewfirstr   r   rn   rb   cached_nodeidsr$   r&   s     r'   r(   zNFPlugin.__init__  sH    mm,,||'''!&,,"2"2?B"GHr)   Tr   c              #    K   d }| j                   ri }i }|D ]9  }|j                  | j                  vr|||j                  <   +|||j                  <   ; | j                  |j	                               | j                  |j	                               z   |d d  | j                  j                  |       |S | j                  j                  d |D               |S w)Nc              3  4   K   | ]  }|j                     y wr#   r   r   s     r'   r   z9NFPlugin.pytest_collection_modifyitems.<locals>.<genexpr>  s     &Eutt{{us   )r   r   r  _get_increasing_ordervaluesr   )r$   r   rS   	new_itemsother_itemsr   s         r'   r   z&NFPlugin.pytest_collection_modifyitems  s     ;;/1I13K;;d&9&99-1Idkk*/3K,	  11  "**;+=+=+?@AE!H &&y1 
 &&&Eu&EE
s   CCc                     t        |d d      S )Nc                J    | j                   j                         j                  S r#   )rK   statst_mtime)r   s    r'   <lambda>z0NFPlugin._get_increasing_order.<locals>.<lambda>  s    diinn.>.G.Gr)   Tr   )r   )r$   r   s     r'   r  zNFPlugin._get_increasing_order  s    e!GQUVVr)   c                    | j                   }|j                  d      st        |d      ry |j                  d      ry |j                  J |j                  j	                  dt        | j                               y )Nr   r   collectonlyr   )r&   r-   r   r   rn   r   r  r  s     r'   r   zNFPlugin.pytest_sessionfinish  se    K(GFM,JM*||'''&1D1D*EFr)   Nr   )r   r   r   r   )r   zIterable[nodes.Item]r   r   r   )	r   r   r   r   r(   r   r   r  r   r>   r)   r'   r   r     s2    BI dT* +*W	Gr)   r   c           	        | j                  d      }|j                  ddddd       |j                  dd	dd
d       |j                  ddddd       |j                  ddddd       |j                  dddd       d}dt        j                  v r1t        j                  j                  t        j                  d   |      }| j                  d|d       |j                  ddd d!d"d#d$%       y )&Ngeneralz--lfz--last-failed
store_truer   zHRerun only the tests that failed at the last run (or all if none failed))actiondesthelpz--ffz--failed-firstr   zyRun all tests, but run the last failures first. This may re-order tests and thus lead to repeated fixture setup/teardown.z--nfz--new-firstr  zORun tests from new files first, then the rest of the tests sorted by file mtimez--cache-showr   ?r   z_Show cache contents, don't perform collection or tests. Optional argument: glob (default: '*').)r  nargsr  r  z--cache-clearr+   z.Remove all cache contents at start of test run.pytest_cacheTOX_ENV_DIRr7   zCache directory path)r`   r  z--lfnfz--last-failed-no-failuresstorer   )allr   r  a  With ``--lf``, determines whether to execute tests when there are no previously (known) failures or when no cached ``lastfailed`` data was found. ``all`` (the default) runs the full test suite again. ``none`` just emits a message about no known failures and exits successfully.)r  r  choicesr`   r  )getgroup	addoptionrv   environrK   joinaddini)parsergroupcache_dir_defaults      r'   pytest_addoptionr&    s-   OOI&E	OO2   
OO+   
OO   
OO6  	 
OO=	   (

"GGLLM)BDUV
MM+'8?UMV	OO#&X  r)   c                    | j                   j                  r)| j                   j                  sddlm}  || t              S y )Nr   )wrap_session)r   r   r  _pytest.mainr(  )r&   r(  s     r'   pytest_cmdline_mainr*    s.    }}v}}'9'9-FI..r)   T)r   c                    t         j                  | d      | _        | j                  j	                  t        |       d       | j                  j	                  t        |       d       y )NTr    r   nfplugin)r   r1   r   r   r   r   r   )r&   s    r'   pytest_configurer-  $  sO    ##Fd#;FL
!!(6"2J?
!!(6"2J?r)   c                ^    | j                   j                  J | j                   j                  S )ab  Return a cache object that can persist state between testing sessions.

    cache.get(key, default)
    cache.set(key, value)

    Keys must be ``/`` separated strings, where the first part is usually the
    name of your plugin or application to avoid clashes with other cache users.

    Values can be any object handled by the json stdlib module.
    )r&   r   )requests    r'   r   r   +  s*     >>+++>>r)   c                
   | j                   j                  dkD  s| j                  d      dk7  rE| j                  J | j                  j                  }	 |j                  | j                        }d| S y# t        $ r |}Y w xY w)z6Display cachedir with --cache-show and if non-default.r   r7   r  N
cachedir: )r   verboser8   r   r   relative_tor9   rP   )r&   r%   displaypaths      r'   pytest_report_headerr5  ;  s    }}q FMM+$>/$Q||'''<<))	#"..v?K K=))  	#"K	#s   A4 4BBc                   ddl m} | j                  J t               }|j	                  dt        | j                  j                        z          | j                  j                  j                         s|j	                  d       y| j                  j                  d   }|d}t               }| j                  j                  }|t        j                  z  }|j                  dd|       t        d |j                  |      D              D ]  }t        |j!                  |            }	| j                  j#                  |	|      }
|
|u r|j	                  |	 d	       R|j	                  |	 d
        ||
      j%                         D ]  }|j	                  d|z            |t        j&                  z  }|j                         rt        |j                  |            }|j                  dd|       |D ]\  }|j)                         st        |j!                  |            }	|j	                  |	 d|j+                         j,                  d       ^ y)Nr   )pformatr1  zcache is empty*-zcache values for c              3  B   K   | ]  }|j                         s|  y wr#   )is_file)r   rr   s     r'   r   zcacheshow.<locals>.<genexpr>^  s     E%5!%5s   z- contains unreadable content, will be ignoredz
 contains:z  zcache directories for z is a file of length r   )pprintr7  r   r   liner   r   r.   r   r   r   r   r4   sepr   rglobr3  rb   
splitlinesr3   r;  r  st_size)r&   r   r7  twglobdummybasedirvdirvalpathrU   valr=  ddircontentsps                  r'   r   r   K  s   <<###		BGGL3v||55667<<!!((*
 !==""1%D|HEll$$GU///DFF3#D8,-ETZZ%5EE'%%d+,llsE*%<GGseHIJGGse:&'//1t$ 2 F U---D{{}$**T*+
s,TH56A yy{!--013%4QVVX5E5Ea4HIJ  r)   )r#  r   r   r   )r&   r   r   zint | ExitCode | Noner   )r/  r   r   r   )r&   r   r   r   )r&   r   r   r   r   int)6r   
__future__r   r   r|   r]   rv   pathlibr   rt   typingr   r   r   r	   r
   reportsr   _pytestr   _pytest._ior   _pytest.configr   r   r   _pytest.config.argparsingr   _pytest.deprecatedr   _pytest.fixturesr   r   r)  r   _pytest.nodesr   r   _pytest.reportsr   ry   rz   	dataclassr   r   r   r   r   r&  r*  r-  r   r5  r   r>   r)   r'   <module>rZ     s   + #    	      %  "  & ! # # , - $ +   #  &	  } }  }@1 1h $nB nBb+G +G\;| 
4@ @ 	  	  'r)   